#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define vc vector
#define vi vector<int>
#define si(x) ((int)x.size())
#define pb push_back
#define fi first
#define se second
using pii = pair<int,int>;
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
int chk[3][3] = {0};
int OO[3][3] = {0};
for(int i=0;i<7;i++){
chk[R[i]%3][C[i]%3]=1;
}
vc<pii>V;
vc<pii>U;
int NN[7];
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(!chk[i][j] && si(V) < 2){
V.pb({i,j});
}
}
}
if(V[0] > V[1])swap(V[0],V[1]);
if(V[0].fi == V[1].fi){
if(V[0].se==0 && V[1].se==2)swap(V[1],V[0]);
}
else if(V[0].fi==0 && V[1].fi==2)swap(V[1],V[0]);
auto [ax,ay] = V[0];
auto [bx,by] = V[1];
for(int i=0;i<3;i++)for(int j=0;j<3;j++)OO[i][j]=0;
OO[ax][ay] = OO[bx][by] = -1;
int c = 0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
int x = (ax + i)%3, y = (ay + j)%3;
if(OO[x][y] != -1){
OO[x][y] = c++;
}
}
}
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(OO[i%3][j%3] != -1){
int a = OO[i%3][j%3];
if(i - R[a] > 1){
SetFlag(i,j,4);
}
else if(i - R[a] < -1){
SetFlag(i,j,3);
}
else if(j - C[a] > 1){
SetFlag(i,j,2);
}
else if(j - C[a] < -1){
SetFlag(i,j,1);
}
else{
SetFlag(i, j, 5 + OO[R[a]%3][C[a]%3]);
}
}
else{
SetFlag(i, j, 12);
}
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define vc vector
#define vi vector<int>
#define si(x) ((int)x.size())
#define pb push_back
#define fi first
#define se second
std::vector<int> Bruno(int K, std::vector<int> value) {
vc<pii>V;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(value[i*3+j] == 12){
V.pb({i,j});
}
}
}
int chk[3][3] = {0};
int OO[3][3] = {0};
if(V[0] > V[1])swap(V[0],V[1]);
if(V[0].fi == V[1].fi){
if(V[0].se==0 && V[1].se==2)swap(V[1],V[0]);
}
else if(V[0].fi==0 && V[1].fi==2)swap(V[1],V[0]);
auto [ax,ay] = V[0];
auto [bx,by] = V[1];
for(int i=0;i<3;i++)for(int j=0;j<3;j++)OO[i][j]=0;
OO[ax][ay] = OO[bx][by] = -1;
int c = 0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
int x = (ax + i)%3, y = (ay + j)%3;
if(OO[x][y] != -1){
OO[x][y] = c++;
}
}
}
vi R(7);
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
int a = value[i*3+j];
if(OO[i][j]!=-1){
if(a<=4){
R[OO[i][j]] = a-1;
}
else{
a-=5;
int xx, yy;
for(int k=i-1;k<=i+1;k++){
for(int l=j-1;l<=j+1;l++){
if(OO[(k+3)%3][(l+3)%3] == a){
xx=k, yy=l;
}
}
}
int t = 4;
if(1 > xx)t = 3;
else if(1 < xx)t = 2;
else if(1 > yy)t = 1;
else if(1 < yy)t = 0;
//printf("%d %d %d %d %d\n",a,i,j,xx,yy);
R[OO[i][j]] = t;
}
}
}
}
return R;
}
Compilation message
Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:24:9: warning: unused variable 'NN' [-Wunused-variable]
24 | int NN[7];
| ^~
Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:22:9: warning: unused variable 'chk' [-Wunused-variable]
22 | int chk[3][3] = {0};
| ^~~
Bruno.cpp:68:26: warning: 'yy' may be used uninitialized in this function [-Wmaybe-uninitialized]
68 | else if(1 < yy)t = 0;
| ^~
Bruno.cpp:66:26: warning: 'xx' may be used uninitialized in this function [-Wmaybe-uninitialized]
66 | else if(1 < xx)t = 2;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
384 KB |
Output is correct |
2 |
Correct |
14 ms |
384 KB |
Output is correct |
3 |
Correct |
15 ms |
384 KB |
Output is correct |
4 |
Correct |
13 ms |
384 KB |
Output is correct |
5 |
Correct |
17 ms |
384 KB |
Output is correct |
6 |
Correct |
16 ms |
384 KB |
Output is correct |
7 |
Correct |
13 ms |
388 KB |
Output is correct |
8 |
Correct |
18 ms |
384 KB |
Output is correct |
9 |
Correct |
16 ms |
384 KB |
Output is correct |
10 |
Correct |
16 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
384 KB |
Output is correct |
12 |
Correct |
13 ms |
384 KB |
Output is correct |
13 |
Correct |
16 ms |
468 KB |
Output is correct |
14 |
Correct |
12 ms |
392 KB |
Output is correct |
15 |
Correct |
16 ms |
468 KB |
Output is correct |
16 |
Correct |
18 ms |
388 KB |
Output is correct |
17 |
Correct |
15 ms |
384 KB |
Output is correct |
18 |
Correct |
13 ms |
384 KB |
Output is correct |
19 |
Correct |
12 ms |
388 KB |
Output is correct |
20 |
Correct |
17 ms |
384 KB |
Output is correct |
21 |
Correct |
15 ms |
384 KB |
Output is correct |
22 |
Correct |
17 ms |
384 KB |
Output is correct |
23 |
Correct |
13 ms |
384 KB |
Output is correct |
24 |
Correct |
18 ms |
384 KB |
Output is correct |
25 |
Correct |
13 ms |
384 KB |
Output is correct |
26 |
Correct |
18 ms |
388 KB |
Output is correct |
27 |
Correct |
17 ms |
384 KB |
Output is correct |
28 |
Correct |
13 ms |
384 KB |
Output is correct |
29 |
Correct |
16 ms |
448 KB |
Output is correct |
30 |
Correct |
16 ms |
384 KB |
Output is correct |
31 |
Correct |
16 ms |
464 KB |
Output is correct |
32 |
Correct |
13 ms |
384 KB |
Output is correct |
33 |
Correct |
12 ms |
384 KB |
Output is correct |
34 |
Correct |
13 ms |
384 KB |
Output is correct |
35 |
Correct |
15 ms |
384 KB |
Output is correct |
36 |
Correct |
16 ms |
384 KB |
Output is correct |
37 |
Correct |
14 ms |
384 KB |
Output is correct |
38 |
Correct |
16 ms |
384 KB |
Output is correct |
39 |
Correct |
16 ms |
384 KB |
Output is correct |
40 |
Correct |
13 ms |
468 KB |
Output is correct |
41 |
Correct |
19 ms |
384 KB |
Output is correct |
42 |
Correct |
18 ms |
384 KB |
Output is correct |
43 |
Correct |
13 ms |
384 KB |
Output is correct |
44 |
Correct |
18 ms |
384 KB |
Output is correct |
45 |
Correct |
15 ms |
384 KB |
Output is correct |
46 |
Correct |
17 ms |
384 KB |
Output is correct |
47 |
Correct |
19 ms |
384 KB |
Output is correct |
48 |
Correct |
15 ms |
384 KB |
Output is correct |
49 |
Correct |
18 ms |
384 KB |
Output is correct |
50 |
Correct |
15 ms |
384 KB |
Output is correct |
51 |
Correct |
16 ms |
388 KB |
Output is correct |
52 |
Correct |
16 ms |
384 KB |
Output is correct |
53 |
Correct |
14 ms |
384 KB |
Output is correct |
54 |
Correct |
15 ms |
384 KB |
Output is correct |
55 |
Correct |
19 ms |
384 KB |
Output is correct |
56 |
Correct |
20 ms |
388 KB |
Output is correct |
57 |
Correct |
22 ms |
384 KB |
Output is correct |
58 |
Correct |
16 ms |
448 KB |
Output is correct |
59 |
Correct |
20 ms |
384 KB |
Output is correct |
60 |
Correct |
22 ms |
384 KB |
Output is correct |
61 |
Correct |
22 ms |
384 KB |
Output is correct |
62 |
Correct |
27 ms |
384 KB |
Output is correct |
63 |
Correct |
19 ms |
384 KB |
Output is correct |
64 |
Correct |
20 ms |
508 KB |
Output is correct |
65 |
Correct |
24 ms |
384 KB |
Output is correct |
66 |
Correct |
23 ms |
384 KB |
Output is correct |
67 |
Correct |
24 ms |
404 KB |
Output is correct |
68 |
Correct |
19 ms |
384 KB |
Output is correct |
69 |
Correct |
19 ms |
388 KB |
Output is correct |
70 |
Correct |
24 ms |
384 KB |
Output is correct |
71 |
Correct |
18 ms |
512 KB |
Output is correct |
72 |
Correct |
20 ms |
384 KB |
Output is correct |
73 |
Correct |
19 ms |
384 KB |
Output is correct |
74 |
Correct |
22 ms |
384 KB |
Output is correct |
75 |
Correct |
21 ms |
384 KB |
Output is correct |
76 |
Correct |
18 ms |
384 KB |
Output is correct |
77 |
Correct |
17 ms |
384 KB |
Output is correct |
78 |
Correct |
20 ms |
384 KB |
Output is correct |
79 |
Correct |
18 ms |
384 KB |
Output is correct |
80 |
Correct |
22 ms |
384 KB |
Output is correct |
81 |
Correct |
22 ms |
384 KB |
Output is correct |
82 |
Correct |
18 ms |
384 KB |
Output is correct |
83 |
Correct |
22 ms |
384 KB |
Output is correct |
84 |
Correct |
19 ms |
384 KB |
Output is correct |
85 |
Correct |
21 ms |
468 KB |
Output is correct |
86 |
Correct |
19 ms |
384 KB |
Output is correct |
87 |
Correct |
20 ms |
468 KB |
Output is correct |
88 |
Correct |
23 ms |
384 KB |
Output is correct |
89 |
Correct |
20 ms |
388 KB |
Output is correct |
90 |
Correct |
20 ms |
384 KB |
Output is correct |
91 |
Correct |
19 ms |
384 KB |
Output is correct |
92 |
Correct |
20 ms |
384 KB |
Output is correct |
93 |
Correct |
23 ms |
468 KB |
Output is correct |
94 |
Correct |
22 ms |
384 KB |
Output is correct |
95 |
Correct |
18 ms |
472 KB |
Output is correct |
96 |
Correct |
19 ms |
384 KB |
Output is correct |
97 |
Correct |
20 ms |
384 KB |
Output is correct |
98 |
Correct |
19 ms |
384 KB |
Output is correct |
99 |
Correct |
25 ms |
396 KB |
Output is correct |
100 |
Correct |
18 ms |
464 KB |
Output is correct |
101 |
Correct |
19 ms |
384 KB |
Output is correct |
102 |
Correct |
19 ms |
384 KB |
Output is correct |
103 |
Correct |
19 ms |
384 KB |
Output is correct |
104 |
Correct |
22 ms |
384 KB |
Output is correct |
105 |
Correct |
19 ms |
384 KB |
Output is correct |
106 |
Correct |
22 ms |
384 KB |
Output is correct |
107 |
Correct |
20 ms |
384 KB |
Output is correct |
108 |
Correct |
19 ms |
384 KB |
Output is correct |
109 |
Correct |
20 ms |
384 KB |
Output is correct |
110 |
Correct |
16 ms |
392 KB |
Output is correct |
111 |
Correct |
24 ms |
388 KB |
Output is correct |
112 |
Correct |
20 ms |
388 KB |
Output is correct |
113 |
Correct |
19 ms |
476 KB |
Output is correct |
114 |
Correct |
18 ms |
384 KB |
Output is correct |
115 |
Correct |
20 ms |
388 KB |
Output is correct |
116 |
Correct |
20 ms |
384 KB |
Output is correct |
117 |
Correct |
16 ms |
384 KB |
Output is correct |
118 |
Correct |
21 ms |
384 KB |
Output is correct |
119 |
Correct |
20 ms |
384 KB |
Output is correct |
120 |
Correct |
688 ms |
548 KB |
Output is correct |
121 |
Correct |
707 ms |
668 KB |
Output is correct |
122 |
Correct |
730 ms |
536 KB |
Output is correct |
123 |
Correct |
770 ms |
560 KB |
Output is correct |
124 |
Correct |
737 ms |
568 KB |
Output is correct |
125 |
Correct |
730 ms |
664 KB |
Output is correct |
126 |
Correct |
776 ms |
676 KB |
Output is correct |
127 |
Correct |
698 ms |
576 KB |
Output is correct |
128 |
Correct |
672 ms |
608 KB |
Output is correct |
129 |
Correct |
698 ms |
588 KB |
Output is correct |
130 |
Correct |
735 ms |
900 KB |
Output is correct |
131 |
Correct |
838 ms |
652 KB |
Output is correct |
132 |
Correct |
716 ms |
624 KB |
Output is correct |
133 |
Correct |
731 ms |
588 KB |
Output is correct |
134 |
Correct |
709 ms |
604 KB |
Output is correct |
135 |
Correct |
777 ms |
548 KB |
Output is correct |
136 |
Correct |
695 ms |
500 KB |
Output is correct |
137 |
Correct |
707 ms |
700 KB |
Output is correct |
138 |
Correct |
806 ms |
616 KB |
Output is correct |
139 |
Correct |
874 ms |
740 KB |
Output is correct |
140 |
Correct |
701 ms |
620 KB |
Output is correct |
141 |
Correct |
714 ms |
704 KB |
Output is correct |
142 |
Correct |
871 ms |
652 KB |
Output is correct |
143 |
Correct |
692 ms |
524 KB |
Output is correct |
144 |
Correct |
720 ms |
736 KB |
Output is correct |
145 |
Correct |
789 ms |
584 KB |
Output is correct |
146 |
Correct |
758 ms |
572 KB |
Output is correct |
147 |
Correct |
793 ms |
688 KB |
Output is correct |
148 |
Correct |
709 ms |
548 KB |
Output is correct |
149 |
Correct |
704 ms |
668 KB |
Output is correct |
150 |
Correct |
690 ms |
604 KB |
Output is correct |
151 |
Correct |
773 ms |
672 KB |
Output is correct |
152 |
Correct |
780 ms |
688 KB |
Output is correct |
153 |
Correct |
741 ms |
712 KB |
Output is correct |
154 |
Correct |
680 ms |
592 KB |
Output is correct |
155 |
Correct |
696 ms |
664 KB |
Output is correct |
156 |
Correct |
688 ms |
600 KB |
Output is correct |
157 |
Correct |
703 ms |
568 KB |
Output is correct |
158 |
Correct |
769 ms |
612 KB |
Output is correct |
159 |
Correct |
690 ms |
696 KB |
Output is correct |
160 |
Correct |
698 ms |
636 KB |
Output is correct |
161 |
Correct |
726 ms |
624 KB |
Output is correct |
162 |
Correct |
735 ms |
596 KB |
Output is correct |
163 |
Correct |
727 ms |
644 KB |
Output is correct |
164 |
Correct |
767 ms |
580 KB |
Output is correct |
165 |
Correct |
708 ms |
724 KB |
Output is correct |
166 |
Correct |
673 ms |
696 KB |
Output is correct |
167 |
Correct |
721 ms |
660 KB |
Output is correct |
168 |
Correct |
732 ms |
564 KB |
Output is correct |
169 |
Correct |
693 ms |
600 KB |
Output is correct |
170 |
Correct |
761 ms |
732 KB |
Output is correct |
171 |
Correct |
675 ms |
696 KB |
Output is correct |
172 |
Correct |
709 ms |
592 KB |
Output is correct |
173 |
Correct |
792 ms |
756 KB |
Output is correct |
174 |
Correct |
771 ms |
588 KB |
Output is correct |
175 |
Correct |
711 ms |
640 KB |
Output is correct |
176 |
Correct |
723 ms |
608 KB |
Output is correct |
177 |
Correct |
689 ms |
568 KB |
Output is correct |
178 |
Correct |
865 ms |
652 KB |
Output is correct |
179 |
Correct |
733 ms |
596 KB |
Output is correct |
180 |
Correct |
689 ms |
688 KB |
Output is correct |
181 |
Correct |
667 ms |
536 KB |
Output is correct |
182 |
Correct |
668 ms |
656 KB |
Output is correct |
183 |
Correct |
677 ms |
684 KB |
Output is correct |
184 |
Correct |
698 ms |
736 KB |
Output is correct |
185 |
Correct |
709 ms |
628 KB |
Output is correct |
186 |
Correct |
807 ms |
608 KB |
Output is correct |
187 |
Correct |
665 ms |
776 KB |
Output is correct |
188 |
Correct |
673 ms |
648 KB |
Output is correct |
189 |
Correct |
669 ms |
776 KB |
Output is correct |
190 |
Correct |
699 ms |
768 KB |
Output is correct |
191 |
Correct |
675 ms |
800 KB |
Output is correct |
192 |
Correct |
673 ms |
624 KB |
Output is correct |
193 |
Correct |
665 ms |
664 KB |
Output is correct |
194 |
Correct |
694 ms |
604 KB |
Output is correct |
195 |
Correct |
679 ms |
660 KB |
Output is correct |
196 |
Correct |
667 ms |
668 KB |
Output is correct |
197 |
Correct |
681 ms |
664 KB |
Output is correct |
198 |
Correct |
668 ms |
584 KB |
Output is correct |
199 |
Correct |
686 ms |
648 KB |
Output is correct |
200 |
Correct |
725 ms |
624 KB |
Output is correct |
201 |
Correct |
694 ms |
632 KB |
Output is correct |
202 |
Correct |
680 ms |
596 KB |
Output is correct |
203 |
Correct |
687 ms |
548 KB |
Output is correct |
204 |
Correct |
733 ms |
596 KB |
Output is correct |
205 |
Correct |
708 ms |
736 KB |
Output is correct |
206 |
Correct |
667 ms |
680 KB |
Output is correct |
207 |
Correct |
679 ms |
576 KB |
Output is correct |
208 |
Correct |
730 ms |
564 KB |
Output is correct |
209 |
Correct |
748 ms |
664 KB |
Output is correct |
210 |
Correct |
511 ms |
700 KB |
Output is correct |
211 |
Correct |
552 ms |
696 KB |
Output is correct |
212 |
Correct |
507 ms |
692 KB |
Output is correct |
213 |
Correct |
533 ms |
660 KB |
Output is correct |
214 |
Correct |
558 ms |
584 KB |
Output is correct |
215 |
Correct |
512 ms |
640 KB |
Output is correct |
216 |
Correct |
520 ms |
596 KB |
Output is correct |
217 |
Correct |
517 ms |
680 KB |
Output is correct |
218 |
Correct |
528 ms |
800 KB |
Output is correct |
219 |
Correct |
530 ms |
680 KB |
Output is correct |
220 |
Correct |
522 ms |
536 KB |
Output is correct |
221 |
Correct |
532 ms |
604 KB |
Output is correct |
222 |
Correct |
508 ms |
692 KB |
Output is correct |
223 |
Correct |
627 ms |
520 KB |
Output is correct |
224 |
Correct |
549 ms |
500 KB |
Output is correct |
225 |
Correct |
508 ms |
492 KB |
Output is correct |
226 |
Correct |
558 ms |
592 KB |
Output is correct |