#include<bits/stdc++.h>
#include "Anna.h"
using namespace std;
typedef int ll;
void Anna(ll N, ll K, vector<ll> R, vector<ll> C) {
ll x,y,z,w,n,k,i,j,a[400][400],b[3][3]={},c[1100]={},t,l;
vector<ll> u,v;
pair<ll,ll> p[7]={{-1,-1},{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1}};
n=N;
k=7;
for(i=0;i<400;i++)
for(j=0;j<400;j++)
a[i][j]=0;
v=R; u=C;
for(i=0;i<k;i++)
{
v[i]++;
u[i]++;
}
x=-1; y=-1;
for(i=0;i<k;i++)
b[(v[i]+2+2-p[i].first)%3][(u[i]+2+2-p[i].second)%3]=1;
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
{
if(b[i][j]==0)
{
x=i; y=j;
// printf("%lld %lld\n",x,y);
break;
}
}
if(x>=0)
break;
}
x-=3; y-=3;
for(i=x;i<=n;i+=3)
{
for(j=y;j<=n;j+=3)
{
if(i>=1&&j>=1)
a[i][j]=13;
}
}
for(l=0;l<7;l++)
{
z=x+p[l].first;
w=y+p[l].second;
for(i=z;i<=n;i+=3)
for(j=w;j<=n;j+=3)
{
if(i<1||j<1)
{
continue;
}
if((i+1)==v[l]&&(j+1)==u[l])
{
a[i][j]=5;
}
else if((i+1)==v[l]&&(j)==u[l])
{
a[i][j]=6;
}
else if((i+1)==v[l]&&(j-1)==u[l])
{
a[i][j]=7;
}
else if((i)==v[l]&&(j+1)==u[l])
{
a[i][j]=8;
}
else if((i)==v[l]&&(j)==u[l])
{
a[i][j]=9;
}
else if((i)==v[l]&&(j-1)==u[l])
{
a[i][j]=10;
}
else if((i-1)==v[l]&&(j+1)==u[l])
{
a[i][j]=11;
}
else if((i-1)==v[l]&&(j)==u[l])
{
a[i][j]=12;
}
else if((i-1)==v[l]&&(j-1)==u[l])
{
a[i][j]=13;
}
else if((j-2)>=u[l])
{
a[i][j]=2;
}
else if((j+2)<=u[l])
{
a[i][j]=1;
}
else if((i-2)>=v[l])
{
a[i][j]=4;
}
else if((i+2)<=v[l])
{
a[i][j]=3;
}
}
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
c[a[i][j]]=1;
for(i=1;i<=12;i++)
{
if(c[i]==0)
{
t=i;
break;
}
}
z=x-3; w=y-4;
for(i=z;i<=n;i+=3)
for(j=w;j<=n;j+=3)
{
if(i>=1&&j>=1)
a[i][j]=t;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
if(a[i][j]>t)
a[i][j]--;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
SetFlag(i-1,j-1,a[i][j]);
}
#include<bits/stdc++.h>
#include "Bruno.h"
using namespace std;
typedef int ll;
vector<ll> Bruno(ll K,vector<ll> value) {
ll x,y,i,j,n,k,a[110][110],z,w,t,l,x1,y1,s=0;
k=7;
pair<ll,ll> p[7]={{2,2},{2,0},{2,1},{0,1},{1,1},{1,0},{1,2}};
vector<ll> v;
v.resize(7);
n=3;
for(i=0;i<(n*n);i++)
a[i/3][i%3]=value[i];
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
{
// printf("%lld ",a[i][j]);
if(a[i][j]==12)
{
x=i; y=j;
s++;
}
}
}
if(s==2)
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(a[i][j]==12&&a[i][(j+2)%3]==12)
{
x=i; y=j;
}
}
}
}
t=a[(x)%3][(y+2)%3];
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
if(a[i][j]>=t)
a[i][j]++;
}
for(l=0;l<k;l++)
{
z=(x+p[l].first)%3;
w=(y+p[l].second)%3;
x1=z; y1=w;
if(a[z][w]==1)
{
v[l]=0;
continue;
}
else if(a[z][w]==2)
{
v[l]=1;
continue;
}
else if(a[z][w]==3)
{
v[l]=2;
continue;
}
else if(a[z][w]==4)
{
v[l]=3;
continue;
}
else if(a[z][w]==5)
{
x1++; y1++;
}
else if(a[z][w]==6)
{
x1++;
}
else if(a[z][w]==7)
{
x1++; y1--;
}
else if(a[z][w]==8)
{
y1++;
}
else if(a[z][w]==9)
{
}
else if(a[z][w]==10)
{
y1--;
}
else if(a[z][w]==11)
{
x1--; y1++;
}
else if(a[z][w]==12)
{
x1--;
}
else if(a[z][w]==13)
{
x1--; y1--;
}
if(x1==1&&y1==1)
{
v[l]=4;
continue;
}
if(x1==1)
{
if(y1>1)
{
v[l]=0;
}
else
v[l]=1;
}
else
{
if(x1>1)
{
v[l]=2;
}
else
v[l]=3;
continue;
}
}
return v;
}
Compilation message
Anna.cpp: In function 'void Anna(ll, ll, std::vector<int>, std::vector<int>)':
Anna.cpp:11:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
11 | for(i=0;i<400;i++)
| ^~~
Anna.cpp:14:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
14 | v=R; u=C;
| ^
Anna.cpp:127:12: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
127 | a[i][j]=t;
| ~~~~~~~^~
Bruno.cpp: In function 'std::vector<int> Bruno(ll, std::vector<int>)':
Bruno.cpp:48:13: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
48 | w=(y+p[l].second)%3;
| ~~^~~~~~~~~~~~~
Bruno.cpp:47:13: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
47 | z=(x+p[l].first)%3;
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1168 KB |
Output is correct |
2 |
Correct |
20 ms |
1168 KB |
Output is correct |
3 |
Correct |
20 ms |
1168 KB |
Output is correct |
4 |
Correct |
19 ms |
1168 KB |
Output is correct |
5 |
Correct |
26 ms |
1168 KB |
Output is correct |
6 |
Correct |
21 ms |
1168 KB |
Output is correct |
7 |
Correct |
23 ms |
1168 KB |
Output is correct |
8 |
Correct |
17 ms |
1124 KB |
Output is correct |
9 |
Correct |
20 ms |
1168 KB |
Output is correct |
10 |
Correct |
24 ms |
1168 KB |
Output is correct |
11 |
Correct |
22 ms |
1168 KB |
Output is correct |
12 |
Correct |
20 ms |
1168 KB |
Output is correct |
13 |
Correct |
18 ms |
1168 KB |
Output is correct |
14 |
Correct |
16 ms |
1128 KB |
Output is correct |
15 |
Correct |
22 ms |
1168 KB |
Output is correct |
16 |
Correct |
15 ms |
1124 KB |
Output is correct |
17 |
Correct |
22 ms |
1168 KB |
Output is correct |
18 |
Correct |
18 ms |
1124 KB |
Output is correct |
19 |
Correct |
21 ms |
1168 KB |
Output is correct |
20 |
Correct |
25 ms |
1168 KB |
Output is correct |
21 |
Correct |
26 ms |
1168 KB |
Output is correct |
22 |
Correct |
21 ms |
1128 KB |
Output is correct |
23 |
Correct |
20 ms |
1168 KB |
Output is correct |
24 |
Correct |
23 ms |
1168 KB |
Output is correct |
25 |
Correct |
26 ms |
1168 KB |
Output is correct |
26 |
Correct |
21 ms |
1124 KB |
Output is correct |
27 |
Correct |
26 ms |
1168 KB |
Output is correct |
28 |
Correct |
18 ms |
1168 KB |
Output is correct |
29 |
Correct |
22 ms |
1168 KB |
Output is correct |
30 |
Correct |
18 ms |
1168 KB |
Output is correct |
31 |
Correct |
25 ms |
1164 KB |
Output is correct |
32 |
Correct |
25 ms |
1168 KB |
Output is correct |
33 |
Correct |
24 ms |
1168 KB |
Output is correct |
34 |
Correct |
19 ms |
1168 KB |
Output is correct |
35 |
Correct |
18 ms |
1168 KB |
Output is correct |
36 |
Correct |
23 ms |
1168 KB |
Output is correct |
37 |
Correct |
27 ms |
1120 KB |
Output is correct |
38 |
Correct |
25 ms |
1168 KB |
Output is correct |
39 |
Correct |
23 ms |
1124 KB |
Output is correct |
40 |
Correct |
25 ms |
1168 KB |
Output is correct |
41 |
Correct |
20 ms |
1168 KB |
Output is correct |
42 |
Correct |
20 ms |
1168 KB |
Output is correct |
43 |
Correct |
30 ms |
1168 KB |
Output is correct |
44 |
Correct |
28 ms |
1168 KB |
Output is correct |
45 |
Correct |
18 ms |
1124 KB |
Output is correct |
46 |
Correct |
20 ms |
1168 KB |
Output is correct |
47 |
Correct |
26 ms |
1168 KB |
Output is correct |
48 |
Correct |
27 ms |
1168 KB |
Output is correct |
49 |
Correct |
21 ms |
1128 KB |
Output is correct |
50 |
Correct |
30 ms |
1176 KB |
Output is correct |
51 |
Correct |
22 ms |
1116 KB |
Output is correct |
52 |
Correct |
23 ms |
1168 KB |
Output is correct |
53 |
Correct |
23 ms |
1168 KB |
Output is correct |
54 |
Correct |
23 ms |
1168 KB |
Output is correct |
55 |
Correct |
24 ms |
1168 KB |
Output is correct |
56 |
Correct |
27 ms |
1168 KB |
Output is correct |
57 |
Correct |
26 ms |
1168 KB |
Output is correct |
58 |
Correct |
22 ms |
1128 KB |
Output is correct |
59 |
Correct |
27 ms |
1168 KB |
Output is correct |
60 |
Correct |
28 ms |
1168 KB |
Output is correct |
61 |
Correct |
31 ms |
1168 KB |
Output is correct |
62 |
Correct |
19 ms |
1120 KB |
Output is correct |
63 |
Correct |
25 ms |
1168 KB |
Output is correct |
64 |
Correct |
26 ms |
1124 KB |
Output is correct |
65 |
Correct |
31 ms |
1168 KB |
Output is correct |
66 |
Correct |
28 ms |
1168 KB |
Output is correct |
67 |
Correct |
30 ms |
1168 KB |
Output is correct |
68 |
Correct |
26 ms |
1168 KB |
Output is correct |
69 |
Correct |
23 ms |
1168 KB |
Output is correct |
70 |
Correct |
31 ms |
1168 KB |
Output is correct |
71 |
Correct |
33 ms |
1168 KB |
Output is correct |
72 |
Correct |
26 ms |
1128 KB |
Output is correct |
73 |
Correct |
28 ms |
1168 KB |
Output is correct |
74 |
Correct |
31 ms |
1168 KB |
Output is correct |
75 |
Correct |
30 ms |
1168 KB |
Output is correct |
76 |
Correct |
21 ms |
1120 KB |
Output is correct |
77 |
Correct |
19 ms |
1120 KB |
Output is correct |
78 |
Correct |
23 ms |
1168 KB |
Output is correct |
79 |
Correct |
23 ms |
1168 KB |
Output is correct |
80 |
Correct |
33 ms |
1168 KB |
Output is correct |
81 |
Correct |
22 ms |
1168 KB |
Output is correct |
82 |
Correct |
30 ms |
1168 KB |
Output is correct |
83 |
Correct |
24 ms |
1168 KB |
Output is correct |
84 |
Correct |
30 ms |
1168 KB |
Output is correct |
85 |
Correct |
30 ms |
1168 KB |
Output is correct |
86 |
Correct |
32 ms |
1168 KB |
Output is correct |
87 |
Correct |
22 ms |
1168 KB |
Output is correct |
88 |
Correct |
20 ms |
1168 KB |
Output is correct |
89 |
Correct |
25 ms |
1168 KB |
Output is correct |
90 |
Correct |
24 ms |
1168 KB |
Output is correct |
91 |
Correct |
24 ms |
1168 KB |
Output is correct |
92 |
Correct |
26 ms |
1168 KB |
Output is correct |
93 |
Correct |
26 ms |
1168 KB |
Output is correct |
94 |
Correct |
27 ms |
1168 KB |
Output is correct |
95 |
Correct |
26 ms |
1168 KB |
Output is correct |
96 |
Correct |
23 ms |
1124 KB |
Output is correct |
97 |
Correct |
23 ms |
1168 KB |
Output is correct |
98 |
Correct |
27 ms |
1168 KB |
Output is correct |
99 |
Correct |
30 ms |
1128 KB |
Output is correct |
100 |
Correct |
22 ms |
1124 KB |
Output is correct |
101 |
Correct |
20 ms |
1124 KB |
Output is correct |
102 |
Correct |
23 ms |
1168 KB |
Output is correct |
103 |
Correct |
29 ms |
1120 KB |
Output is correct |
104 |
Correct |
31 ms |
1168 KB |
Output is correct |
105 |
Correct |
20 ms |
1168 KB |
Output is correct |
106 |
Correct |
26 ms |
1168 KB |
Output is correct |
107 |
Correct |
28 ms |
1168 KB |
Output is correct |
108 |
Correct |
33 ms |
1168 KB |
Output is correct |
109 |
Correct |
32 ms |
1168 KB |
Output is correct |
110 |
Correct |
25 ms |
1168 KB |
Output is correct |
111 |
Correct |
25 ms |
1168 KB |
Output is correct |
112 |
Correct |
31 ms |
1168 KB |
Output is correct |
113 |
Correct |
28 ms |
1168 KB |
Output is correct |
114 |
Correct |
27 ms |
1168 KB |
Output is correct |
115 |
Correct |
27 ms |
1180 KB |
Output is correct |
116 |
Correct |
24 ms |
1120 KB |
Output is correct |
117 |
Correct |
28 ms |
1168 KB |
Output is correct |
118 |
Correct |
25 ms |
1124 KB |
Output is correct |
119 |
Correct |
24 ms |
1168 KB |
Output is correct |
120 |
Correct |
709 ms |
1436 KB |
Output is correct |
121 |
Correct |
741 ms |
1488 KB |
Output is correct |
122 |
Correct |
741 ms |
1336 KB |
Output is correct |
123 |
Correct |
735 ms |
1400 KB |
Output is correct |
124 |
Correct |
829 ms |
1364 KB |
Output is correct |
125 |
Correct |
783 ms |
1312 KB |
Output is correct |
126 |
Correct |
786 ms |
1356 KB |
Output is correct |
127 |
Correct |
909 ms |
1304 KB |
Output is correct |
128 |
Correct |
749 ms |
1288 KB |
Output is correct |
129 |
Correct |
739 ms |
1348 KB |
Output is correct |
130 |
Correct |
764 ms |
1336 KB |
Output is correct |
131 |
Correct |
793 ms |
1364 KB |
Output is correct |
132 |
Correct |
773 ms |
1300 KB |
Output is correct |
133 |
Correct |
767 ms |
1344 KB |
Output is correct |
134 |
Correct |
836 ms |
1360 KB |
Output is correct |
135 |
Correct |
800 ms |
1372 KB |
Output is correct |
136 |
Correct |
829 ms |
1348 KB |
Output is correct |
137 |
Correct |
766 ms |
1264 KB |
Output is correct |
138 |
Correct |
816 ms |
1368 KB |
Output is correct |
139 |
Correct |
847 ms |
1404 KB |
Output is correct |
140 |
Correct |
857 ms |
1384 KB |
Output is correct |
141 |
Correct |
909 ms |
1368 KB |
Output is correct |
142 |
Correct |
861 ms |
1356 KB |
Output is correct |
143 |
Correct |
800 ms |
1264 KB |
Output is correct |
144 |
Correct |
828 ms |
1380 KB |
Output is correct |
145 |
Correct |
753 ms |
1288 KB |
Output is correct |
146 |
Correct |
760 ms |
1468 KB |
Output is correct |
147 |
Correct |
676 ms |
1468 KB |
Output is correct |
148 |
Correct |
799 ms |
1316 KB |
Output is correct |
149 |
Correct |
651 ms |
1412 KB |
Output is correct |
150 |
Correct |
716 ms |
1420 KB |
Output is correct |
151 |
Correct |
667 ms |
1312 KB |
Output is correct |
152 |
Correct |
754 ms |
1388 KB |
Output is correct |
153 |
Correct |
674 ms |
1244 KB |
Output is correct |
154 |
Correct |
724 ms |
1468 KB |
Output is correct |
155 |
Correct |
814 ms |
1376 KB |
Output is correct |
156 |
Correct |
747 ms |
1548 KB |
Output is correct |
157 |
Correct |
716 ms |
1404 KB |
Output is correct |
158 |
Correct |
796 ms |
1396 KB |
Output is correct |
159 |
Correct |
699 ms |
1348 KB |
Output is correct |
160 |
Correct |
698 ms |
1388 KB |
Output is correct |
161 |
Correct |
728 ms |
1412 KB |
Output is correct |
162 |
Correct |
727 ms |
1256 KB |
Output is correct |
163 |
Correct |
760 ms |
1368 KB |
Output is correct |
164 |
Correct |
685 ms |
1292 KB |
Output is correct |
165 |
Correct |
720 ms |
1400 KB |
Output is correct |
166 |
Correct |
669 ms |
1476 KB |
Output is correct |
167 |
Correct |
786 ms |
1460 KB |
Output is correct |
168 |
Correct |
681 ms |
1408 KB |
Output is correct |
169 |
Correct |
727 ms |
1380 KB |
Output is correct |
170 |
Correct |
740 ms |
1364 KB |
Output is correct |
171 |
Correct |
702 ms |
1460 KB |
Output is correct |
172 |
Correct |
681 ms |
1336 KB |
Output is correct |
173 |
Correct |
766 ms |
1352 KB |
Output is correct |
174 |
Correct |
692 ms |
1416 KB |
Output is correct |
175 |
Correct |
742 ms |
1448 KB |
Output is correct |
176 |
Correct |
698 ms |
1524 KB |
Output is correct |
177 |
Correct |
797 ms |
1532 KB |
Output is correct |
178 |
Correct |
720 ms |
1352 KB |
Output is correct |
179 |
Correct |
742 ms |
1492 KB |
Output is correct |
180 |
Correct |
717 ms |
1412 KB |
Output is correct |
181 |
Correct |
680 ms |
1392 KB |
Output is correct |
182 |
Correct |
751 ms |
1392 KB |
Output is correct |
183 |
Correct |
790 ms |
1508 KB |
Output is correct |
184 |
Correct |
707 ms |
1480 KB |
Output is correct |
185 |
Correct |
830 ms |
1452 KB |
Output is correct |
186 |
Correct |
690 ms |
1296 KB |
Output is correct |
187 |
Correct |
757 ms |
1420 KB |
Output is correct |
188 |
Correct |
761 ms |
1324 KB |
Output is correct |
189 |
Correct |
799 ms |
1380 KB |
Output is correct |
190 |
Correct |
848 ms |
1408 KB |
Output is correct |
191 |
Correct |
726 ms |
1292 KB |
Output is correct |
192 |
Correct |
643 ms |
1464 KB |
Output is correct |
193 |
Correct |
676 ms |
1384 KB |
Output is correct |
194 |
Correct |
740 ms |
1400 KB |
Output is correct |
195 |
Correct |
758 ms |
1400 KB |
Output is correct |
196 |
Correct |
742 ms |
1448 KB |
Output is correct |
197 |
Correct |
776 ms |
1364 KB |
Output is correct |
198 |
Correct |
747 ms |
1360 KB |
Output is correct |
199 |
Correct |
770 ms |
1372 KB |
Output is correct |
200 |
Correct |
781 ms |
1384 KB |
Output is correct |
201 |
Correct |
660 ms |
1412 KB |
Output is correct |
202 |
Correct |
647 ms |
1452 KB |
Output is correct |
203 |
Correct |
738 ms |
1292 KB |
Output is correct |
204 |
Correct |
765 ms |
1320 KB |
Output is correct |
205 |
Correct |
705 ms |
1484 KB |
Output is correct |
206 |
Correct |
744 ms |
1456 KB |
Output is correct |
207 |
Correct |
629 ms |
1424 KB |
Output is correct |
208 |
Correct |
660 ms |
1420 KB |
Output is correct |
209 |
Correct |
652 ms |
1400 KB |
Output is correct |
210 |
Correct |
480 ms |
1392 KB |
Output is correct |
211 |
Correct |
508 ms |
1520 KB |
Output is correct |
212 |
Correct |
556 ms |
1340 KB |
Output is correct |
213 |
Correct |
551 ms |
1456 KB |
Output is correct |
214 |
Correct |
544 ms |
1428 KB |
Output is correct |
215 |
Correct |
516 ms |
1284 KB |
Output is correct |
216 |
Correct |
574 ms |
1340 KB |
Output is correct |
217 |
Correct |
479 ms |
1284 KB |
Output is correct |
218 |
Correct |
494 ms |
1272 KB |
Output is correct |
219 |
Correct |
529 ms |
1344 KB |
Output is correct |
220 |
Correct |
533 ms |
1420 KB |
Output is correct |
221 |
Correct |
477 ms |
1492 KB |
Output is correct |
222 |
Correct |
489 ms |
1476 KB |
Output is correct |
223 |
Correct |
542 ms |
1464 KB |
Output is correct |
224 |
Correct |
637 ms |
1300 KB |
Output is correct |
225 |
Correct |
528 ms |
1580 KB |
Output is correct |
226 |
Correct |
523 ms |
1300 KB |
Output is correct |