Return to Snippet

Revision: 48377
at June 30, 2011 01:28 by Nursoltan


Initial Code
/*
  NAME : Nursoltan
  PROB : clocks
  LANG : C++ 
  DATE : 29/06/11 23:28
*/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <sstream>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <utility>
#include <queue>

using namespace std;

#define MAX 100
#define INF INT_MAX
#define eps (1e-9)

#define FOR(_i,_k,_n) for((_i)=(_k); (_i)<(_n); (_i)++)
#define FORR(_i,_k,_n) for(int (_i)=(_k); (_i)>=(_n); (_i)--)
#define CLR(_x) memset((_x),0,sizeof(_x))
#define SQR(_x) ((_x)*(_x))
#define all(_x) _x.begin(),_x.end()
#define sz(_x) sizeof(_x)

#define vc vector<int>
#define pb push_back
#define mp make_pair
#define iss istringstream
#define oss ostringstream
#define px first
#define py second

typedef long long ll;
typedef pair <int,int> point;
int ABS(int _x){ return _x>0?_x:-_x; }

vector<int> b;

void proc(int i, int ordk){
    b[i]=b[i]+ordk*3;
    if(b[i]>12) b[i]%=12;
}

int main()
{
    freopen("clocks.in","r",stdin);
    freopen("clocks.out","w",stdout);
    
    int k,i,j;
    vector<int> a(9),dest(9);
    FOR(i,0,9) cin>>a[i],dest[i]=12; 
    
    int ord[9]={0};
    FOR(ord[0],0,4) FOR(ord[1],0,4) FOR(ord[2],0,4)
    FOR(ord[3],0,4) FOR(ord[4],0,4) FOR(ord[5],0,4)
    FOR(ord[6],0,4) FOR(ord[7],0,4) FOR(ord[8],0,4){
      b=a;
      proc(0,ord[0]); proc(1,ord[0]); proc(3,ord[0]); proc(4,ord[0]);
      proc(0,ord[1]); proc(1,ord[1]); proc(2,ord[1]); 
      proc(1,ord[2]); proc(2,ord[2]); proc(4,ord[2]); proc(5,ord[2]);
      proc(0,ord[3]); proc(3,ord[3]); proc(6,ord[3]); 
      proc(1,ord[4]); proc(3,ord[4]); proc(7,ord[4]); proc(5,ord[4]); proc(4,ord[4]);
      proc(2,ord[5]); proc(5,ord[5]); proc(8,ord[5]); 
      proc(3,ord[6]); proc(4,ord[6]); proc(6,ord[6]); proc(7,ord[6]);
      proc(6,ord[7]); proc(7,ord[7]); proc(8,ord[7]); 
      proc(4,ord[8]); proc(5,ord[8]); proc(7,ord[8]); proc(8,ord[8]);
      
      if(b==dest){
        int k=0;
        FOR(i,0,9) FOR(j,0,ord[i]){ if(k) cout<<" "; cout<<i+1; k=1; }
        cout<<endl;
        goto GOTOHELL;
      }
    }
    
    GOTOHELL : 
    //system("pause");
    return 0;
}

Initial URL

                                

Initial Description

                                

Initial Title
ch1 : The Clocks

Initial Tags

                                

Initial Language
C++