File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < cstdio>
2+ #include < deque>
3+ #include < cmath>
4+ using namespace std ;
5+
6+ deque<int > sawtooth[4 ];
7+ int K;
8+ bool isCheck[4 ];
9+ int answer = 0 ;
10+ void Input (){
11+ char dir;
12+ for (int i=0 ; i<4 ; i++){
13+ for (int j=0 ; j<8 ; j++){
14+ scanf (" %c" , &dir);
15+ if (j==7 ) getchar ();
16+ sawtooth[i].push_back (dir - ' 0' );
17+ }
18+ }
19+ scanf (" %d" , &K);
20+ }
21+
22+ void Rotate (int Num, int rotation){
23+ int right, left;
24+ right = sawtooth[Num][2 ];
25+ left = sawtooth[Num][6 ];
26+ isCheck[Num] = true ;
27+
28+ if (rotation == -1 ){
29+ int front = sawtooth[Num].front ();
30+ sawtooth[Num].pop_front ();
31+ sawtooth[Num].push_back (front);
32+ }
33+ else {
34+ int back = sawtooth[Num].back ();
35+ sawtooth[Num].pop_back ();
36+ sawtooth[Num].push_front (back);
37+ }
38+
39+ if (Num < 3 && !isCheck[Num+1 ] && right!=sawtooth[Num+1 ][6 ])
40+ Rotate (Num+1 , -rotation);
41+
42+ if (Num > 0 && !isCheck[Num-1 ] && left!=sawtooth[Num-1 ][2 ])
43+ Rotate (Num-1 , -rotation);
44+ }
45+
46+ void Solution (){
47+ int Num, rotation, score;
48+ for (int i=0 ; i<K; i++){
49+ scanf (" %d %d" , &Num, &rotation);
50+ Num--;
51+ for (int i=0 ; i<4 ; i++)
52+ isCheck[i] = false ;
53+ Rotate (Num, rotation);
54+ }
55+
56+ for (int i=0 ; i<4 ; i++){
57+ score = sawtooth[i].front ();
58+ if (score == 1 )
59+ answer += pow (2 , i);
60+ }
61+ printf (" %d\n " , answer);
62+ }
63+
64+ int main (){
65+ Input ();
66+ Solution ();
67+ }
You can’t perform that action at this time.
0 commit comments