// Hex.cc // 2012 ECNA - Hex Game #include using namespace std; #define IFDB if(DEBUG) const bool DEBUG = false; #define FOR(i,n) for(int i=0;i>n; FOR(x,n){ //get Tiles FOR(i,7) FOR(j,6) cin>>Tile[i][j]; done = false; //try each tile at position 0 FOR(t0,7){ //rotate until t0[0]==1 while(Tile[t0][0]!=1) rotate(Tile[t0]); //now try tiles at pos 1 FOR(t1,7) if(t0!=t1){ while(Tile[t1][0]!=1) rotate(Tile[t1]); //now try at pos 2 FOR(t2,7) if(t2!=t1 && t2 !=t0) { while(Tile[t2][0]!=Tile[t0][1]) rotate(Tile[t2]); //proceed to t3 if match to t1 if(Tile[t2][1] == Tile[t1][5]) FOR(t3,7) if(t3!=t2 && t3!=t1 && t3!=t0){ while(Tile[t3][0]!=Tile[t0][2]) rotate(Tile[t3]); //proceed to t4 if match to t2 if(Tile[t3][1]==Tile[t2][5]) FOR(t4,7) if(t4!=t3 && t4!=t2 && t4!=t1 && t4!=t0){ while(Tile[t4][0]!=Tile[t0][3]) rotate(Tile[t4]); //proceed to t5? if(Tile[t4][1]==Tile[t3][5]) FOR(t5,7) if(t5!=t4 && t5!=t3 && t5!=t2 && t5!=t1 && t5 !=t0){ while(Tile[t5][0]!=Tile[t0][4]) rotate(Tile[t5]); //proceed to t6? if(Tile[t5][1]==Tile[t4][5]) FOR(t6,7) if(t6!=t5 && t6!=t4 && t6!=t3 && t6!=t2 && t6!=t1 && t6!=t0){ while(Tile[t6][0]!=Tile[t0][5]) rotate(Tile[t6]); //proceed to t7? if(Tile[t6][1]==Tile[t5][5]) //have we found a solution? if(Tile[t6][1]==Tile[t5][5] && Tile[t6][5]==Tile[t1][1]) { done=true; cout<<"Case "<