#include "Anna.h"
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
#define MP make_pair
void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
ll type[3][3];
bool oc[3][3];
for (ll i = 0;i < 3;i ++)for (ll j = 0;j < 3;j ++)oc[i][j] = 0;
for (ll i = 0;i < K;i ++){oc[R[i]%3][C[i]%3] = 1;}
vector <pll> tmp;
for (ll i = 0;i < 3;i ++)for (ll j = 0;j < 3;j ++){
if (oc[i][j] == 0)tmp.push_back(MP(i,j));
}
pll dist;
dist.fi = (tmp[1].fi-tmp[0].fi+3)%3;
if (dist.fi==2)dist.fi = -1;
dist.se = (tmp[1].se-tmp[0].se+3)%3;
if (dist.se==2)dist.se = -1;
if (dist < MP(0LL,0LL))swap(tmp[0],tmp[1]);
for (ll i = 0;i < 3;i ++){
for (ll j = 0;j < 3;j ++){
ll x = (i - tmp[0].fi + 3) % 3;
ll y = (j - tmp[0].se + 3) % 3;
type[i][j] = x*3+y;
}
}
ll A = 0,B = type[tmp[1].fi][tmp[1].se];
vector <ll> p(9);
for (ll i = 0,ptr = 0;i < 9;i ++){
if (i==A||i==B)continue;
p[i] = ptr++;
}
for (int r = 0; r < N; r++) {
for (int c = 0; c < N; c++) {
ll t = type[r%3][c%3];
ll id = p[t];
if (t==A||t==B){
SetFlag(r,c,12);
}
else{
ll res = -1;
if (abs(R[id] - r) >= 2){
if (R[id] > r)res = 10;
else res = 11;
}
else if (abs(C[id] - c) >= 2){
if (C[id] > c)res = 8;
else res = 9;
}
else{
for (ll i = -1,ptr = 1;i <= 1;i ++){
for (ll j = -1;j <= 1;j ++){
ll x = (i + t/3 + 3) % 3;
ll y = (j + t%3 + 3) % 3;
ll t1 = x*3+y;
if (t1==A||t1==B)continue;
if (R[id] == r + i && C[id] == c + j){
res = ptr;
}
ptr++;
}
}
}
SetFlag(r,c,res);
}
}
}
}
#include "Bruno.h"
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
#define MP make_pair
std::vector<int> Bruno(int K, std::vector<int> value) {
vector <vector <ll > > val(3,vector <ll> (3));
for (ll i = 0;i < 9;i ++)val[i/3][i%3] = value[i];
vector <vector <ll> > type(3,vector<ll> (3));
vector <pll> tmp;
for (ll i = 0;i < 3;i ++){
for (ll j = 0;j < 3;j ++){
if (val[i][j] == 12){
tmp.push_back(MP(i,j));
}
}
}
pll dist;
dist.fi = (tmp[1].fi-tmp[0].fi+3)%3;
if (dist.fi==2)dist.fi = -1;
dist.se = (tmp[1].se-tmp[0].se+3)%3;
if (dist.se==2)dist.se = -1;
if (dist < MP(0LL,0LL))swap(tmp[0],tmp[1]);
for (ll i = 0;i < 3;i ++){
for (ll j = 0;j < 3;j ++){
ll x = (i - tmp[0].fi + 3) % 3;
ll y = (j - tmp[0].se + 3) % 3;
type[i][j] = x*3+y;
}
}
ll A = 0,B = type[tmp[1].fi][tmp[1].se];
vector <ll> p(9);
for (ll i = 0,ptr = 0;i < 9;i ++){
if (i==A||i==B)continue;
p[i] = ptr++;
}
// for (ll i = 0;i < 3;i ++){
// for (ll j = 0;j < 3;j ++)cout<<val[i][j]<<' ';
// cout<<'\n';
// }
vector <int> res(K);
for (ll i = 0;i < 3;i ++){
for (ll j = 0;j < 3;j ++){
ll t = type[i][j];
ll id = p[t];
if (t==A||t==B)continue;
auto &ans = res[id];
if (val[i][j] <= 7){
ll ni,nj;
for (ll i1 = -1,ptr = 1;i1 <= 1;i1 ++){
for (ll j1 = -1;j1 <= 1;j1 ++){
ll x = (i1 + t/3 + 3) % 3;
ll y = (j1 + t%3 + 3) % 3;
ll t1 = x*3+y;
if (t1==A||t1==B)continue;
if (ptr == val[i][j]){
ni = i + i1,nj = j + j1;
}
ptr++;
}
}
if (nj > 1)ans = 0;
else if (nj < 1)ans = 1;
else if (ni > 1)ans = 2;
else if (ni < 1)ans = 3;
else ans = 4;
}
else{
ans = val[i][j] - 8;
}
}
}
return res;
}
Compilation message
Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:73:22: warning: 'nj' may be used uninitialized in this function [-Wmaybe-uninitialized]
73 | else if (nj < 1)ans = 1;
| ^~
Bruno.cpp:75:22: warning: 'ni' may be used uninitialized in this function [-Wmaybe-uninitialized]
75 | else if (ni < 1)ans = 3;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
664 KB |
Output is correct |
2 |
Correct |
6 ms |
664 KB |
Output is correct |
3 |
Correct |
9 ms |
664 KB |
Output is correct |
4 |
Correct |
8 ms |
664 KB |
Output is correct |
5 |
Correct |
7 ms |
664 KB |
Output is correct |
6 |
Correct |
7 ms |
664 KB |
Output is correct |
7 |
Correct |
9 ms |
748 KB |
Output is correct |
8 |
Correct |
8 ms |
664 KB |
Output is correct |
9 |
Correct |
8 ms |
664 KB |
Output is correct |
10 |
Correct |
8 ms |
664 KB |
Output is correct |
11 |
Correct |
9 ms |
664 KB |
Output is correct |
12 |
Correct |
7 ms |
664 KB |
Output is correct |
13 |
Correct |
7 ms |
664 KB |
Output is correct |
14 |
Correct |
6 ms |
664 KB |
Output is correct |
15 |
Correct |
6 ms |
664 KB |
Output is correct |
16 |
Correct |
7 ms |
668 KB |
Output is correct |
17 |
Correct |
7 ms |
664 KB |
Output is correct |
18 |
Correct |
8 ms |
664 KB |
Output is correct |
19 |
Correct |
8 ms |
664 KB |
Output is correct |
20 |
Correct |
8 ms |
664 KB |
Output is correct |
21 |
Correct |
8 ms |
664 KB |
Output is correct |
22 |
Correct |
9 ms |
664 KB |
Output is correct |
23 |
Correct |
7 ms |
664 KB |
Output is correct |
24 |
Correct |
6 ms |
664 KB |
Output is correct |
25 |
Correct |
7 ms |
664 KB |
Output is correct |
26 |
Correct |
10 ms |
664 KB |
Output is correct |
27 |
Correct |
8 ms |
664 KB |
Output is correct |
28 |
Correct |
7 ms |
664 KB |
Output is correct |
29 |
Correct |
7 ms |
664 KB |
Output is correct |
30 |
Correct |
10 ms |
664 KB |
Output is correct |
31 |
Correct |
7 ms |
664 KB |
Output is correct |
32 |
Correct |
7 ms |
664 KB |
Output is correct |
33 |
Correct |
6 ms |
664 KB |
Output is correct |
34 |
Correct |
6 ms |
664 KB |
Output is correct |
35 |
Correct |
6 ms |
664 KB |
Output is correct |
36 |
Correct |
10 ms |
664 KB |
Output is correct |
37 |
Correct |
7 ms |
664 KB |
Output is correct |
38 |
Correct |
9 ms |
664 KB |
Output is correct |
39 |
Correct |
10 ms |
664 KB |
Output is correct |
40 |
Correct |
6 ms |
664 KB |
Output is correct |
41 |
Correct |
7 ms |
664 KB |
Output is correct |
42 |
Correct |
8 ms |
664 KB |
Output is correct |
43 |
Correct |
8 ms |
664 KB |
Output is correct |
44 |
Correct |
7 ms |
664 KB |
Output is correct |
45 |
Correct |
8 ms |
664 KB |
Output is correct |
46 |
Correct |
11 ms |
664 KB |
Output is correct |
47 |
Correct |
8 ms |
664 KB |
Output is correct |
48 |
Correct |
10 ms |
664 KB |
Output is correct |
49 |
Correct |
8 ms |
664 KB |
Output is correct |
50 |
Correct |
7 ms |
664 KB |
Output is correct |
51 |
Correct |
8 ms |
664 KB |
Output is correct |
52 |
Correct |
10 ms |
664 KB |
Output is correct |
53 |
Correct |
9 ms |
664 KB |
Output is correct |
54 |
Correct |
9 ms |
664 KB |
Output is correct |
55 |
Correct |
8 ms |
664 KB |
Output is correct |
56 |
Correct |
9 ms |
664 KB |
Output is correct |
57 |
Correct |
8 ms |
664 KB |
Output is correct |
58 |
Correct |
8 ms |
664 KB |
Output is correct |
59 |
Correct |
8 ms |
664 KB |
Output is correct |
60 |
Correct |
9 ms |
664 KB |
Output is correct |
61 |
Correct |
12 ms |
664 KB |
Output is correct |
62 |
Correct |
10 ms |
664 KB |
Output is correct |
63 |
Correct |
11 ms |
664 KB |
Output is correct |
64 |
Correct |
12 ms |
664 KB |
Output is correct |
65 |
Correct |
9 ms |
664 KB |
Output is correct |
66 |
Correct |
13 ms |
664 KB |
Output is correct |
67 |
Correct |
10 ms |
664 KB |
Output is correct |
68 |
Correct |
8 ms |
664 KB |
Output is correct |
69 |
Correct |
11 ms |
664 KB |
Output is correct |
70 |
Correct |
10 ms |
664 KB |
Output is correct |
71 |
Correct |
10 ms |
664 KB |
Output is correct |
72 |
Correct |
14 ms |
664 KB |
Output is correct |
73 |
Correct |
12 ms |
664 KB |
Output is correct |
74 |
Correct |
13 ms |
748 KB |
Output is correct |
75 |
Correct |
9 ms |
664 KB |
Output is correct |
76 |
Correct |
12 ms |
664 KB |
Output is correct |
77 |
Correct |
14 ms |
664 KB |
Output is correct |
78 |
Correct |
12 ms |
664 KB |
Output is correct |
79 |
Correct |
12 ms |
664 KB |
Output is correct |
80 |
Correct |
12 ms |
664 KB |
Output is correct |
81 |
Correct |
9 ms |
664 KB |
Output is correct |
82 |
Correct |
9 ms |
676 KB |
Output is correct |
83 |
Correct |
9 ms |
664 KB |
Output is correct |
84 |
Correct |
10 ms |
664 KB |
Output is correct |
85 |
Correct |
12 ms |
664 KB |
Output is correct |
86 |
Correct |
12 ms |
664 KB |
Output is correct |
87 |
Correct |
13 ms |
664 KB |
Output is correct |
88 |
Correct |
12 ms |
664 KB |
Output is correct |
89 |
Correct |
10 ms |
664 KB |
Output is correct |
90 |
Correct |
9 ms |
664 KB |
Output is correct |
91 |
Correct |
11 ms |
664 KB |
Output is correct |
92 |
Correct |
8 ms |
668 KB |
Output is correct |
93 |
Correct |
9 ms |
664 KB |
Output is correct |
94 |
Correct |
13 ms |
916 KB |
Output is correct |
95 |
Correct |
13 ms |
664 KB |
Output is correct |
96 |
Correct |
8 ms |
664 KB |
Output is correct |
97 |
Correct |
8 ms |
664 KB |
Output is correct |
98 |
Correct |
13 ms |
664 KB |
Output is correct |
99 |
Correct |
12 ms |
664 KB |
Output is correct |
100 |
Correct |
9 ms |
664 KB |
Output is correct |
101 |
Correct |
8 ms |
664 KB |
Output is correct |
102 |
Correct |
13 ms |
664 KB |
Output is correct |
103 |
Correct |
9 ms |
664 KB |
Output is correct |
104 |
Correct |
11 ms |
664 KB |
Output is correct |
105 |
Correct |
11 ms |
664 KB |
Output is correct |
106 |
Correct |
8 ms |
664 KB |
Output is correct |
107 |
Correct |
11 ms |
664 KB |
Output is correct |
108 |
Correct |
14 ms |
664 KB |
Output is correct |
109 |
Correct |
9 ms |
664 KB |
Output is correct |
110 |
Correct |
13 ms |
664 KB |
Output is correct |
111 |
Correct |
8 ms |
664 KB |
Output is correct |
112 |
Correct |
14 ms |
664 KB |
Output is correct |
113 |
Correct |
9 ms |
664 KB |
Output is correct |
114 |
Correct |
13 ms |
744 KB |
Output is correct |
115 |
Correct |
10 ms |
664 KB |
Output is correct |
116 |
Correct |
10 ms |
664 KB |
Output is correct |
117 |
Correct |
9 ms |
664 KB |
Output is correct |
118 |
Correct |
13 ms |
664 KB |
Output is correct |
119 |
Correct |
9 ms |
664 KB |
Output is correct |
120 |
Correct |
358 ms |
912 KB |
Output is correct |
121 |
Correct |
327 ms |
1012 KB |
Output is correct |
122 |
Correct |
331 ms |
1076 KB |
Output is correct |
123 |
Correct |
639 ms |
776 KB |
Output is correct |
124 |
Correct |
647 ms |
788 KB |
Output is correct |
125 |
Correct |
409 ms |
1008 KB |
Output is correct |
126 |
Correct |
509 ms |
980 KB |
Output is correct |
127 |
Correct |
337 ms |
788 KB |
Output is correct |
128 |
Correct |
500 ms |
836 KB |
Output is correct |
129 |
Correct |
326 ms |
796 KB |
Output is correct |
130 |
Correct |
324 ms |
976 KB |
Output is correct |
131 |
Correct |
324 ms |
992 KB |
Output is correct |
132 |
Correct |
453 ms |
924 KB |
Output is correct |
133 |
Correct |
325 ms |
796 KB |
Output is correct |
134 |
Correct |
616 ms |
792 KB |
Output is correct |
135 |
Correct |
332 ms |
1024 KB |
Output is correct |
136 |
Correct |
328 ms |
932 KB |
Output is correct |
137 |
Correct |
329 ms |
908 KB |
Output is correct |
138 |
Correct |
333 ms |
1036 KB |
Output is correct |
139 |
Correct |
466 ms |
804 KB |
Output is correct |
140 |
Correct |
332 ms |
1152 KB |
Output is correct |
141 |
Correct |
597 ms |
812 KB |
Output is correct |
142 |
Correct |
328 ms |
796 KB |
Output is correct |
143 |
Correct |
326 ms |
812 KB |
Output is correct |
144 |
Correct |
399 ms |
940 KB |
Output is correct |
145 |
Correct |
336 ms |
804 KB |
Output is correct |
146 |
Correct |
327 ms |
1020 KB |
Output is correct |
147 |
Correct |
330 ms |
960 KB |
Output is correct |
148 |
Correct |
324 ms |
968 KB |
Output is correct |
149 |
Correct |
474 ms |
1116 KB |
Output is correct |
150 |
Correct |
340 ms |
940 KB |
Output is correct |
151 |
Correct |
330 ms |
1380 KB |
Output is correct |
152 |
Correct |
397 ms |
896 KB |
Output is correct |
153 |
Correct |
416 ms |
1136 KB |
Output is correct |
154 |
Correct |
325 ms |
868 KB |
Output is correct |
155 |
Correct |
375 ms |
1288 KB |
Output is correct |
156 |
Correct |
434 ms |
1012 KB |
Output is correct |
157 |
Correct |
327 ms |
812 KB |
Output is correct |
158 |
Correct |
327 ms |
1352 KB |
Output is correct |
159 |
Correct |
324 ms |
888 KB |
Output is correct |
160 |
Correct |
348 ms |
984 KB |
Output is correct |
161 |
Correct |
341 ms |
976 KB |
Output is correct |
162 |
Correct |
444 ms |
1248 KB |
Output is correct |
163 |
Correct |
335 ms |
980 KB |
Output is correct |
164 |
Correct |
322 ms |
1120 KB |
Output is correct |
165 |
Correct |
497 ms |
1328 KB |
Output is correct |
166 |
Correct |
400 ms |
1464 KB |
Output is correct |
167 |
Correct |
334 ms |
1424 KB |
Output is correct |
168 |
Correct |
360 ms |
1200 KB |
Output is correct |
169 |
Correct |
330 ms |
1476 KB |
Output is correct |
170 |
Correct |
330 ms |
1456 KB |
Output is correct |
171 |
Correct |
339 ms |
1092 KB |
Output is correct |
172 |
Correct |
328 ms |
1036 KB |
Output is correct |
173 |
Correct |
454 ms |
792 KB |
Output is correct |
174 |
Correct |
419 ms |
940 KB |
Output is correct |
175 |
Correct |
356 ms |
844 KB |
Output is correct |
176 |
Correct |
588 ms |
904 KB |
Output is correct |
177 |
Correct |
439 ms |
1216 KB |
Output is correct |
178 |
Correct |
349 ms |
992 KB |
Output is correct |
179 |
Correct |
449 ms |
1084 KB |
Output is correct |
180 |
Correct |
463 ms |
1028 KB |
Output is correct |
181 |
Correct |
475 ms |
1380 KB |
Output is correct |
182 |
Correct |
382 ms |
1176 KB |
Output is correct |
183 |
Correct |
372 ms |
1228 KB |
Output is correct |
184 |
Correct |
364 ms |
1112 KB |
Output is correct |
185 |
Correct |
403 ms |
1336 KB |
Output is correct |
186 |
Correct |
408 ms |
1412 KB |
Output is correct |
187 |
Correct |
436 ms |
956 KB |
Output is correct |
188 |
Correct |
379 ms |
868 KB |
Output is correct |
189 |
Correct |
350 ms |
980 KB |
Output is correct |
190 |
Correct |
358 ms |
1116 KB |
Output is correct |
191 |
Correct |
542 ms |
980 KB |
Output is correct |
192 |
Correct |
472 ms |
1396 KB |
Output is correct |
193 |
Correct |
379 ms |
1188 KB |
Output is correct |
194 |
Correct |
613 ms |
1004 KB |
Output is correct |
195 |
Correct |
381 ms |
1112 KB |
Output is correct |
196 |
Correct |
511 ms |
1256 KB |
Output is correct |
197 |
Correct |
429 ms |
972 KB |
Output is correct |
198 |
Correct |
520 ms |
792 KB |
Output is correct |
199 |
Correct |
341 ms |
904 KB |
Output is correct |
200 |
Correct |
406 ms |
1096 KB |
Output is correct |
201 |
Correct |
480 ms |
968 KB |
Output is correct |
202 |
Correct |
325 ms |
876 KB |
Output is correct |
203 |
Correct |
387 ms |
876 KB |
Output is correct |
204 |
Correct |
496 ms |
788 KB |
Output is correct |
205 |
Correct |
310 ms |
1364 KB |
Output is correct |
206 |
Correct |
327 ms |
1152 KB |
Output is correct |
207 |
Correct |
319 ms |
936 KB |
Output is correct |
208 |
Correct |
431 ms |
968 KB |
Output is correct |
209 |
Correct |
593 ms |
1316 KB |
Output is correct |
210 |
Correct |
240 ms |
872 KB |
Output is correct |
211 |
Correct |
241 ms |
796 KB |
Output is correct |
212 |
Correct |
250 ms |
800 KB |
Output is correct |
213 |
Correct |
254 ms |
1016 KB |
Output is correct |
214 |
Correct |
287 ms |
1360 KB |
Output is correct |
215 |
Correct |
217 ms |
1308 KB |
Output is correct |
216 |
Correct |
287 ms |
924 KB |
Output is correct |
217 |
Correct |
225 ms |
892 KB |
Output is correct |
218 |
Correct |
251 ms |
880 KB |
Output is correct |
219 |
Correct |
234 ms |
792 KB |
Output is correct |
220 |
Correct |
220 ms |
1016 KB |
Output is correct |
221 |
Correct |
218 ms |
868 KB |
Output is correct |
222 |
Correct |
393 ms |
1064 KB |
Output is correct |
223 |
Correct |
316 ms |
928 KB |
Output is correct |
224 |
Correct |
242 ms |
908 KB |
Output is correct |
225 |
Correct |
290 ms |
1096 KB |
Output is correct |
226 |
Correct |
392 ms |
1632 KB |
Output is correct |