#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
namespace {
int n,k;
vector<int> R,C;
int grid[105][105];
const ii coord[]={{-1,-1},{-1,0},{-1,1},
{0,-1},{0,0},{0,1},
{1,-1},{1,0},{1,1}};
} // namespace
set<int> can(int i,int j){
set<int> s;
rep(x,0,n) rep(y,0,n){
int num=((x+i)%3)*3+((y+j)%3);
if (num==0) ;
else if (num==8) ;
else{
num--;
rep(z,0,9) if (x==R[num]+coord[z].fi && y==C[num]+coord[z].se){
s.insert(z+1);
}
}
}
return s;
}
void Anna(int N, int K, std::vector<int> RR, std::vector<int> CC) {
n=N,k=K;
R=RR,C=CC;
memset(grid,0,sizeof(grid));
int dx,dy;
int useless;
rep(x,0,3) rep(y,0,3) {
auto s=can(x,y);
if (!s.count(9)){
dx=x,dy=y;
rep(z,1,10) if (!s.count(z)){
useless=z;
break;
}
}
}
//cout<<"useless: "<<useless<<endl;
//cout<<"d: "<<dx<<" "<<dy<<endl;
rep(x,0,n) rep(y,0,n){
int num=((x+dx)%3)*3+((y+dy)%3);
if (num==0) grid[x][y]=13;
else if (num==8) grid[x][y]=-1;
else{
num--;
rep(z,0,9) if (x==R[num]+coord[z].fi && y==C[num]+coord[z].se){
grid[x][y]=z+1;
}
if (grid[x][y]==0){
if (C[num]<y-1) grid[x][y]=9;
else if (y+1<C[num]) grid[x][y]=10;
else if (R[num]<x-1) grid[x][y]=11;
else if (x+1<R[num]) grid[x][y]=12;
}
}
}
/*
rep(x,0,n){
rep(y,0,n) cout<<grid[x][y]<<" "; cout<<endl;
}
//*/
rep(x,0,n) rep(y,0,n) if (grid[x][y]>=useless) grid[x][y]--;
rep(x,0,n) rep(y,0,n) if (grid[x][y]==-1) grid[x][y]=useless;
/*
rep(x,0,n){
rep(y,0,n) cout<<grid[x][y]<<" "; cout<<endl;
}
//*/
rep(x,0,n) rep(y,0,n) SetFlag(x,y,grid[x][y]);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
namespace {
int k;
const ii coord[]={{-1,-1},{-1,0},{-1,1},
{0,-1},{0,0},{0,1},
{1,-1},{1,0},{1,1}};
} // namespace
std::vector<int> Bruno(int K, std::vector<int> value) {
k=K;
int px,py;
rep(x,0,9) if (value[x]==12){
px=x/3,py=x%3;
}
int useless=value[(px+2)%3*3+(py+2)%3];
//cout<<"b useless: "<<useless<<endl;
vector<int> ans;
rep(x,0,k){
int dx=(px+(x+1)/3)%3;
int dy=(py+(x+1))%3;
int i=dx*3+dy;
if (value[i]>=useless) value[i]++;
if (value[i]<=8){
int ddx=(dx-1)-coord[value[i]-1].fi;
int ddy=(dy-1)-coord[value[i]-1].se;
//cout<<"???: "<<value[i]<<endl;
//cout<<x<<" "<<ddx<<" "<<ddy<<endl;
if (ddy>0) ans.pub(0);
else if (ddy<0) ans.pub(1);
else if (ddx>0) ans.pub(2);
else if (ddx<0) ans.pub(3);
else ans.pub(4);
}
else if (value[i]==9) ans.pub(1);
else if (value[i]==10) ans.pub(0);
else if (value[i]==11) ans.pub(3);
else if (value[i]==12) ans.pub(2);
}
//for (auto &it:ans) cout<<it<<" "; cout<<endl;
return ans;
}
Compilation message
Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:100:54: warning: 'useless' may be used uninitialized in this function [-Wmaybe-uninitialized]
100 | rep(x,0,n) rep(y,0,n) if (grid[x][y]==-1) grid[x][y]=useless;
| ~~~~~~~~~~^~~~~~~~
Anna.cpp:75:27: warning: 'dy' may be used uninitialized in this function [-Wmaybe-uninitialized]
75 | int num=((x+dx)%3)*3+((y+dy)%3);
| ~~^~~~
Anna.cpp:75:14: warning: 'dx' may be used uninitialized in this function [-Wmaybe-uninitialized]
75 | int num=((x+dx)%3)*3+((y+dy)%3);
| ~~^~~~
Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:45:13: warning: 'py' may be used uninitialized in this function [-Wmaybe-uninitialized]
45 | int dy=(py+(x+1))%3;
| ~~~^~~~~~~
Bruno.cpp:44:13: warning: 'px' may be used uninitialized in this function [-Wmaybe-uninitialized]
44 | int dx=(px+(x+1)/3)%3;
| ~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
512 KB |
Output is correct |
2 |
Correct |
15 ms |
512 KB |
Output is correct |
3 |
Correct |
17 ms |
512 KB |
Output is correct |
4 |
Correct |
19 ms |
512 KB |
Output is correct |
5 |
Correct |
19 ms |
512 KB |
Output is correct |
6 |
Correct |
22 ms |
512 KB |
Output is correct |
7 |
Correct |
20 ms |
600 KB |
Output is correct |
8 |
Correct |
18 ms |
512 KB |
Output is correct |
9 |
Correct |
19 ms |
512 KB |
Output is correct |
10 |
Correct |
23 ms |
512 KB |
Output is correct |
11 |
Correct |
18 ms |
512 KB |
Output is correct |
12 |
Correct |
17 ms |
516 KB |
Output is correct |
13 |
Correct |
26 ms |
512 KB |
Output is correct |
14 |
Correct |
23 ms |
512 KB |
Output is correct |
15 |
Correct |
24 ms |
512 KB |
Output is correct |
16 |
Correct |
17 ms |
512 KB |
Output is correct |
17 |
Correct |
20 ms |
512 KB |
Output is correct |
18 |
Correct |
23 ms |
512 KB |
Output is correct |
19 |
Correct |
21 ms |
388 KB |
Output is correct |
20 |
Correct |
18 ms |
512 KB |
Output is correct |
21 |
Correct |
20 ms |
512 KB |
Output is correct |
22 |
Correct |
20 ms |
516 KB |
Output is correct |
23 |
Correct |
18 ms |
512 KB |
Output is correct |
24 |
Correct |
21 ms |
512 KB |
Output is correct |
25 |
Correct |
24 ms |
512 KB |
Output is correct |
26 |
Correct |
17 ms |
512 KB |
Output is correct |
27 |
Correct |
17 ms |
512 KB |
Output is correct |
28 |
Correct |
19 ms |
512 KB |
Output is correct |
29 |
Correct |
16 ms |
512 KB |
Output is correct |
30 |
Correct |
18 ms |
512 KB |
Output is correct |
31 |
Correct |
19 ms |
512 KB |
Output is correct |
32 |
Correct |
16 ms |
600 KB |
Output is correct |
33 |
Correct |
20 ms |
512 KB |
Output is correct |
34 |
Correct |
22 ms |
512 KB |
Output is correct |
35 |
Correct |
17 ms |
512 KB |
Output is correct |
36 |
Correct |
20 ms |
516 KB |
Output is correct |
37 |
Correct |
18 ms |
512 KB |
Output is correct |
38 |
Correct |
25 ms |
512 KB |
Output is correct |
39 |
Correct |
19 ms |
512 KB |
Output is correct |
40 |
Correct |
16 ms |
512 KB |
Output is correct |
41 |
Correct |
24 ms |
512 KB |
Output is correct |
42 |
Correct |
22 ms |
512 KB |
Output is correct |
43 |
Correct |
20 ms |
516 KB |
Output is correct |
44 |
Correct |
19 ms |
516 KB |
Output is correct |
45 |
Correct |
20 ms |
512 KB |
Output is correct |
46 |
Correct |
22 ms |
512 KB |
Output is correct |
47 |
Correct |
32 ms |
664 KB |
Output is correct |
48 |
Correct |
26 ms |
512 KB |
Output is correct |
49 |
Correct |
23 ms |
512 KB |
Output is correct |
50 |
Correct |
25 ms |
512 KB |
Output is correct |
51 |
Correct |
22 ms |
512 KB |
Output is correct |
52 |
Correct |
25 ms |
512 KB |
Output is correct |
53 |
Correct |
27 ms |
512 KB |
Output is correct |
54 |
Correct |
20 ms |
592 KB |
Output is correct |
55 |
Correct |
20 ms |
512 KB |
Output is correct |
56 |
Correct |
31 ms |
512 KB |
Output is correct |
57 |
Correct |
26 ms |
512 KB |
Output is correct |
58 |
Correct |
24 ms |
512 KB |
Output is correct |
59 |
Correct |
22 ms |
596 KB |
Output is correct |
60 |
Correct |
24 ms |
512 KB |
Output is correct |
61 |
Correct |
27 ms |
600 KB |
Output is correct |
62 |
Correct |
26 ms |
512 KB |
Output is correct |
63 |
Correct |
29 ms |
600 KB |
Output is correct |
64 |
Correct |
24 ms |
596 KB |
Output is correct |
65 |
Correct |
34 ms |
512 KB |
Output is correct |
66 |
Correct |
30 ms |
516 KB |
Output is correct |
67 |
Correct |
33 ms |
512 KB |
Output is correct |
68 |
Correct |
31 ms |
512 KB |
Output is correct |
69 |
Correct |
28 ms |
512 KB |
Output is correct |
70 |
Correct |
26 ms |
512 KB |
Output is correct |
71 |
Correct |
33 ms |
512 KB |
Output is correct |
72 |
Correct |
34 ms |
576 KB |
Output is correct |
73 |
Correct |
30 ms |
600 KB |
Output is correct |
74 |
Correct |
28 ms |
532 KB |
Output is correct |
75 |
Correct |
26 ms |
520 KB |
Output is correct |
76 |
Correct |
26 ms |
512 KB |
Output is correct |
77 |
Correct |
31 ms |
512 KB |
Output is correct |
78 |
Correct |
33 ms |
384 KB |
Output is correct |
79 |
Correct |
24 ms |
532 KB |
Output is correct |
80 |
Correct |
27 ms |
512 KB |
Output is correct |
81 |
Correct |
28 ms |
512 KB |
Output is correct |
82 |
Correct |
28 ms |
512 KB |
Output is correct |
83 |
Correct |
27 ms |
520 KB |
Output is correct |
84 |
Correct |
27 ms |
512 KB |
Output is correct |
85 |
Correct |
25 ms |
600 KB |
Output is correct |
86 |
Correct |
27 ms |
512 KB |
Output is correct |
87 |
Correct |
32 ms |
512 KB |
Output is correct |
88 |
Correct |
26 ms |
384 KB |
Output is correct |
89 |
Correct |
33 ms |
512 KB |
Output is correct |
90 |
Correct |
31 ms |
512 KB |
Output is correct |
91 |
Correct |
36 ms |
512 KB |
Output is correct |
92 |
Correct |
25 ms |
512 KB |
Output is correct |
93 |
Correct |
27 ms |
512 KB |
Output is correct |
94 |
Correct |
25 ms |
596 KB |
Output is correct |
95 |
Correct |
31 ms |
512 KB |
Output is correct |
96 |
Correct |
28 ms |
512 KB |
Output is correct |
97 |
Correct |
33 ms |
592 KB |
Output is correct |
98 |
Correct |
25 ms |
520 KB |
Output is correct |
99 |
Correct |
26 ms |
512 KB |
Output is correct |
100 |
Correct |
30 ms |
384 KB |
Output is correct |
101 |
Correct |
34 ms |
520 KB |
Output is correct |
102 |
Correct |
27 ms |
512 KB |
Output is correct |
103 |
Correct |
28 ms |
512 KB |
Output is correct |
104 |
Correct |
24 ms |
596 KB |
Output is correct |
105 |
Correct |
30 ms |
512 KB |
Output is correct |
106 |
Correct |
41 ms |
512 KB |
Output is correct |
107 |
Correct |
30 ms |
384 KB |
Output is correct |
108 |
Correct |
25 ms |
512 KB |
Output is correct |
109 |
Correct |
29 ms |
596 KB |
Output is correct |
110 |
Correct |
33 ms |
384 KB |
Output is correct |
111 |
Correct |
31 ms |
512 KB |
Output is correct |
112 |
Correct |
27 ms |
516 KB |
Output is correct |
113 |
Correct |
32 ms |
512 KB |
Output is correct |
114 |
Correct |
27 ms |
512 KB |
Output is correct |
115 |
Correct |
26 ms |
600 KB |
Output is correct |
116 |
Correct |
33 ms |
512 KB |
Output is correct |
117 |
Correct |
27 ms |
512 KB |
Output is correct |
118 |
Correct |
27 ms |
512 KB |
Output is correct |
119 |
Correct |
29 ms |
512 KB |
Output is correct |
120 |
Correct |
1143 ms |
648 KB |
Output is correct |
121 |
Correct |
1130 ms |
780 KB |
Output is correct |
122 |
Correct |
1228 ms |
604 KB |
Output is correct |
123 |
Correct |
1220 ms |
844 KB |
Output is correct |
124 |
Correct |
1229 ms |
744 KB |
Output is correct |
125 |
Correct |
1123 ms |
672 KB |
Output is correct |
126 |
Correct |
1150 ms |
728 KB |
Output is correct |
127 |
Correct |
1162 ms |
828 KB |
Output is correct |
128 |
Correct |
1065 ms |
804 KB |
Output is correct |
129 |
Correct |
1091 ms |
624 KB |
Output is correct |
130 |
Correct |
1220 ms |
796 KB |
Output is correct |
131 |
Correct |
1158 ms |
712 KB |
Output is correct |
132 |
Correct |
1146 ms |
764 KB |
Output is correct |
133 |
Correct |
1251 ms |
792 KB |
Output is correct |
134 |
Correct |
1156 ms |
604 KB |
Output is correct |
135 |
Correct |
1184 ms |
716 KB |
Output is correct |
136 |
Correct |
1105 ms |
808 KB |
Output is correct |
137 |
Correct |
1081 ms |
892 KB |
Output is correct |
138 |
Correct |
1228 ms |
704 KB |
Output is correct |
139 |
Correct |
1083 ms |
944 KB |
Output is correct |
140 |
Correct |
1083 ms |
612 KB |
Output is correct |
141 |
Correct |
1073 ms |
616 KB |
Output is correct |
142 |
Correct |
1132 ms |
724 KB |
Output is correct |
143 |
Correct |
1190 ms |
744 KB |
Output is correct |
144 |
Correct |
1069 ms |
632 KB |
Output is correct |
145 |
Correct |
1159 ms |
816 KB |
Output is correct |
146 |
Correct |
1191 ms |
732 KB |
Output is correct |
147 |
Correct |
1095 ms |
636 KB |
Output is correct |
148 |
Correct |
1114 ms |
632 KB |
Output is correct |
149 |
Correct |
1103 ms |
796 KB |
Output is correct |
150 |
Correct |
1138 ms |
680 KB |
Output is correct |
151 |
Correct |
1097 ms |
768 KB |
Output is correct |
152 |
Correct |
1115 ms |
752 KB |
Output is correct |
153 |
Correct |
1085 ms |
800 KB |
Output is correct |
154 |
Correct |
1120 ms |
580 KB |
Output is correct |
155 |
Correct |
1140 ms |
608 KB |
Output is correct |
156 |
Correct |
1133 ms |
744 KB |
Output is correct |
157 |
Correct |
1055 ms |
704 KB |
Output is correct |
158 |
Correct |
1077 ms |
928 KB |
Output is correct |
159 |
Correct |
1127 ms |
760 KB |
Output is correct |
160 |
Correct |
1113 ms |
660 KB |
Output is correct |
161 |
Correct |
1095 ms |
752 KB |
Output is correct |
162 |
Correct |
1161 ms |
704 KB |
Output is correct |
163 |
Correct |
1236 ms |
636 KB |
Output is correct |
164 |
Correct |
1117 ms |
660 KB |
Output is correct |
165 |
Correct |
1159 ms |
692 KB |
Output is correct |
166 |
Correct |
1137 ms |
776 KB |
Output is correct |
167 |
Correct |
1062 ms |
708 KB |
Output is correct |
168 |
Correct |
1061 ms |
840 KB |
Output is correct |
169 |
Correct |
1093 ms |
764 KB |
Output is correct |
170 |
Correct |
1114 ms |
772 KB |
Output is correct |
171 |
Correct |
1101 ms |
876 KB |
Output is correct |
172 |
Correct |
1068 ms |
792 KB |
Output is correct |
173 |
Correct |
1146 ms |
776 KB |
Output is correct |
174 |
Correct |
1075 ms |
680 KB |
Output is correct |
175 |
Correct |
1163 ms |
684 KB |
Output is correct |
176 |
Correct |
1109 ms |
880 KB |
Output is correct |
177 |
Correct |
1106 ms |
708 KB |
Output is correct |
178 |
Correct |
1183 ms |
792 KB |
Output is correct |
179 |
Correct |
1052 ms |
724 KB |
Output is correct |
180 |
Correct |
1062 ms |
708 KB |
Output is correct |
181 |
Correct |
1091 ms |
732 KB |
Output is correct |
182 |
Correct |
1131 ms |
796 KB |
Output is correct |
183 |
Correct |
1128 ms |
724 KB |
Output is correct |
184 |
Correct |
1078 ms |
776 KB |
Output is correct |
185 |
Correct |
1051 ms |
652 KB |
Output is correct |
186 |
Correct |
1087 ms |
592 KB |
Output is correct |
187 |
Correct |
1146 ms |
824 KB |
Output is correct |
188 |
Correct |
1129 ms |
856 KB |
Output is correct |
189 |
Correct |
1104 ms |
712 KB |
Output is correct |
190 |
Correct |
1059 ms |
768 KB |
Output is correct |
191 |
Correct |
1096 ms |
704 KB |
Output is correct |
192 |
Correct |
1113 ms |
752 KB |
Output is correct |
193 |
Correct |
1199 ms |
768 KB |
Output is correct |
194 |
Correct |
1053 ms |
836 KB |
Output is correct |
195 |
Correct |
1222 ms |
692 KB |
Output is correct |
196 |
Correct |
1101 ms |
784 KB |
Output is correct |
197 |
Correct |
1174 ms |
664 KB |
Output is correct |
198 |
Correct |
1242 ms |
696 KB |
Output is correct |
199 |
Correct |
1232 ms |
792 KB |
Output is correct |
200 |
Correct |
1107 ms |
724 KB |
Output is correct |
201 |
Correct |
1237 ms |
804 KB |
Output is correct |
202 |
Correct |
1132 ms |
724 KB |
Output is correct |
203 |
Correct |
1060 ms |
892 KB |
Output is correct |
204 |
Correct |
1158 ms |
816 KB |
Output is correct |
205 |
Correct |
1099 ms |
744 KB |
Output is correct |
206 |
Correct |
1071 ms |
640 KB |
Output is correct |
207 |
Correct |
1094 ms |
688 KB |
Output is correct |
208 |
Correct |
1064 ms |
972 KB |
Output is correct |
209 |
Correct |
1047 ms |
652 KB |
Output is correct |
210 |
Correct |
810 ms |
740 KB |
Output is correct |
211 |
Correct |
832 ms |
596 KB |
Output is correct |
212 |
Correct |
818 ms |
868 KB |
Output is correct |
213 |
Correct |
841 ms |
692 KB |
Output is correct |
214 |
Correct |
799 ms |
624 KB |
Output is correct |
215 |
Correct |
818 ms |
824 KB |
Output is correct |
216 |
Correct |
848 ms |
644 KB |
Output is correct |
217 |
Correct |
858 ms |
640 KB |
Output is correct |
218 |
Correct |
862 ms |
552 KB |
Output is correct |
219 |
Correct |
822 ms |
596 KB |
Output is correct |
220 |
Correct |
807 ms |
696 KB |
Output is correct |
221 |
Correct |
818 ms |
748 KB |
Output is correct |
222 |
Correct |
872 ms |
760 KB |
Output is correct |
223 |
Correct |
844 ms |
572 KB |
Output is correct |
224 |
Correct |
816 ms |
664 KB |
Output is correct |
225 |
Correct |
838 ms |
668 KB |
Output is correct |
226 |
Correct |
820 ms |
756 KB |
Output is correct |