#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int n, int k, vector<int> r, vector<int> c) {
for (int dx = 0; dx < 3; dx++) for (int dy = 0; dy < 3; dy++) {
vector<int> vis(9, 0), idx(9);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int t = ((i + dx) % 3) * 3 + ((j + dy) % 3);
if (t < 7 && abs(r[t] - i) <= 1 && abs(c[t] - j) <= 1) {
vis[(r[t] - i + 1) * 3 + (c[t] - j + 1)] = 1;
}
}
}
if (vis[8]) continue;
int ty = -1;
for (int i = 0; i < 9; i++) if (!vis[i]) { ty = i; break; }
int cc = 0;
for (int i = 0; i < 8; i++) if (i != ty) idx[i] = ++cc;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int t = ((i + dx) % 3) * 3 + ((j + dy) % 3), cur;
if (t < 7) {
if (abs(r[t] - i) <= 1 && abs(c[t] - j) <= 1) {
cur = idx[(r[t] - i + 1) * 3 + (c[t] - j + 1)];
} else if (c[t] > j + 1) {
cur = 8;
} else if (c[t] < j - 1) {
cur = 9;
} else if (r[t] > i + 1) {
cur = 10;
} else {
cur = 11;
}
} else if (t == 7) {
cur = 12;
} else {
cur = ty + 1;
}
SetFlag(i, j, cur);
}
}
return;
}
assert(false);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
inline int Get(int x, int y, int v, vector<int> bel) {
if (v >= 8) return v - 8;
else {
int nx = x + bel[v - 1] / 3 - 1, ny = y + bel[v - 1] % 3 - 1;
if (ny > 0) return 0;
else if (ny < 0) return 1;
else if (nx > 0) return 2;
else if (nx < 0) return 3;
else return 4;
}
}
}
vector<int> Bruno(int k, vector<int> vec) {
int f1 = -1;
for (int i = 0; i < 9; i++) if (vec[i] == 12) { f1 = i; break; }
vector<int> idx(9);
if (f1 == 7) {
idx[0] = 0;
} else if (f1 == 6) {
idx[0] = 1;
} else if (f1 == 8) {
idx[0] = 2;
} else if (f1 == 4) {
idx[0] = 3;
} else if (f1 == 3) {
idx[0] = 4;
} else if (f1 == 5) {
idx[0] = 5;
} else if (f1 == 1) {
idx[0] = 6;
} else if (f1 == 0) {
idx[0] = 7;
} else if (f1 == 2) {
idx[0] = 8;
}
idx[1] = idx[0] / 3 * 3 + (idx[0] % 3 + 1) % 3;
idx[2] = idx[0] / 3 * 3 + (idx[0] % 3 + 2) % 3;
idx[3] = (idx[0] + 3) % 9;
idx[4] = idx[3] / 3 * 3 + (idx[3] % 3 + 1) % 3;
idx[5] = idx[3] / 3 * 3 + (idx[3] % 3 + 2) % 3;
idx[6] = (idx[3] + 3) % 9;
idx[7] = idx[6] / 3 * 3 + (idx[6] % 3 + 1) % 3;
idx[8] = idx[6] / 3 * 3 + (idx[6] % 3 + 2) % 3;
int ty = -1;
for (int i = 0; i < 9; i++) if (idx[i] == 8) ty = vec[i] - 1;
vector<int> bel(8);
for (int i = 0; i < 8; i++) bel[i] = i;
bel.erase(find(bel.begin(), bel.end(), ty));
vector<int> ret(7);
for (int i = 0; i < 9; i++) if (idx[i] < 7) {
ret[idx[i]] = Get(i / 3 - 1, i % 3 - 1, vec[i], bel);
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
468 KB |
Output is correct |
2 |
Correct |
16 ms |
384 KB |
Output is correct |
3 |
Correct |
13 ms |
384 KB |
Output is correct |
4 |
Correct |
16 ms |
384 KB |
Output is correct |
5 |
Correct |
16 ms |
384 KB |
Output is correct |
6 |
Correct |
16 ms |
384 KB |
Output is correct |
7 |
Correct |
15 ms |
388 KB |
Output is correct |
8 |
Correct |
13 ms |
468 KB |
Output is correct |
9 |
Correct |
12 ms |
464 KB |
Output is correct |
10 |
Correct |
14 ms |
384 KB |
Output is correct |
11 |
Correct |
12 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
384 KB |
Output is correct |
13 |
Correct |
18 ms |
384 KB |
Output is correct |
14 |
Correct |
16 ms |
384 KB |
Output is correct |
15 |
Correct |
14 ms |
468 KB |
Output is correct |
16 |
Correct |
17 ms |
384 KB |
Output is correct |
17 |
Correct |
16 ms |
384 KB |
Output is correct |
18 |
Correct |
19 ms |
388 KB |
Output is correct |
19 |
Correct |
20 ms |
392 KB |
Output is correct |
20 |
Correct |
16 ms |
384 KB |
Output is correct |
21 |
Correct |
15 ms |
388 KB |
Output is correct |
22 |
Correct |
19 ms |
384 KB |
Output is correct |
23 |
Correct |
15 ms |
384 KB |
Output is correct |
24 |
Correct |
14 ms |
384 KB |
Output is correct |
25 |
Correct |
15 ms |
384 KB |
Output is correct |
26 |
Correct |
10 ms |
460 KB |
Output is correct |
27 |
Correct |
14 ms |
384 KB |
Output is correct |
28 |
Correct |
14 ms |
384 KB |
Output is correct |
29 |
Correct |
11 ms |
448 KB |
Output is correct |
30 |
Correct |
12 ms |
492 KB |
Output is correct |
31 |
Correct |
18 ms |
384 KB |
Output is correct |
32 |
Correct |
17 ms |
388 KB |
Output is correct |
33 |
Correct |
15 ms |
388 KB |
Output is correct |
34 |
Correct |
13 ms |
384 KB |
Output is correct |
35 |
Correct |
14 ms |
384 KB |
Output is correct |
36 |
Correct |
15 ms |
384 KB |
Output is correct |
37 |
Correct |
14 ms |
384 KB |
Output is correct |
38 |
Correct |
18 ms |
384 KB |
Output is correct |
39 |
Correct |
20 ms |
384 KB |
Output is correct |
40 |
Correct |
18 ms |
384 KB |
Output is correct |
41 |
Correct |
13 ms |
384 KB |
Output is correct |
42 |
Correct |
16 ms |
384 KB |
Output is correct |
43 |
Correct |
14 ms |
384 KB |
Output is correct |
44 |
Correct |
13 ms |
468 KB |
Output is correct |
45 |
Correct |
18 ms |
384 KB |
Output is correct |
46 |
Correct |
20 ms |
384 KB |
Output is correct |
47 |
Correct |
13 ms |
472 KB |
Output is correct |
48 |
Correct |
19 ms |
384 KB |
Output is correct |
49 |
Correct |
17 ms |
388 KB |
Output is correct |
50 |
Correct |
17 ms |
384 KB |
Output is correct |
51 |
Correct |
17 ms |
384 KB |
Output is correct |
52 |
Correct |
23 ms |
384 KB |
Output is correct |
53 |
Correct |
20 ms |
384 KB |
Output is correct |
54 |
Correct |
17 ms |
384 KB |
Output is correct |
55 |
Correct |
16 ms |
384 KB |
Output is correct |
56 |
Correct |
23 ms |
384 KB |
Output is correct |
57 |
Correct |
25 ms |
384 KB |
Output is correct |
58 |
Correct |
17 ms |
384 KB |
Output is correct |
59 |
Correct |
17 ms |
512 KB |
Output is correct |
60 |
Correct |
23 ms |
384 KB |
Output is correct |
61 |
Correct |
20 ms |
384 KB |
Output is correct |
62 |
Correct |
15 ms |
512 KB |
Output is correct |
63 |
Correct |
19 ms |
388 KB |
Output is correct |
64 |
Correct |
20 ms |
384 KB |
Output is correct |
65 |
Correct |
25 ms |
388 KB |
Output is correct |
66 |
Correct |
21 ms |
468 KB |
Output is correct |
67 |
Correct |
22 ms |
384 KB |
Output is correct |
68 |
Correct |
26 ms |
384 KB |
Output is correct |
69 |
Correct |
18 ms |
384 KB |
Output is correct |
70 |
Correct |
20 ms |
384 KB |
Output is correct |
71 |
Correct |
18 ms |
384 KB |
Output is correct |
72 |
Correct |
19 ms |
388 KB |
Output is correct |
73 |
Correct |
20 ms |
384 KB |
Output is correct |
74 |
Correct |
24 ms |
384 KB |
Output is correct |
75 |
Correct |
23 ms |
388 KB |
Output is correct |
76 |
Correct |
22 ms |
384 KB |
Output is correct |
77 |
Correct |
20 ms |
384 KB |
Output is correct |
78 |
Correct |
24 ms |
384 KB |
Output is correct |
79 |
Correct |
20 ms |
384 KB |
Output is correct |
80 |
Correct |
23 ms |
384 KB |
Output is correct |
81 |
Correct |
19 ms |
384 KB |
Output is correct |
82 |
Correct |
20 ms |
384 KB |
Output is correct |
83 |
Correct |
20 ms |
384 KB |
Output is correct |
84 |
Correct |
19 ms |
384 KB |
Output is correct |
85 |
Correct |
20 ms |
384 KB |
Output is correct |
86 |
Correct |
20 ms |
384 KB |
Output is correct |
87 |
Correct |
20 ms |
388 KB |
Output is correct |
88 |
Correct |
22 ms |
384 KB |
Output is correct |
89 |
Correct |
25 ms |
384 KB |
Output is correct |
90 |
Correct |
22 ms |
472 KB |
Output is correct |
91 |
Correct |
20 ms |
384 KB |
Output is correct |
92 |
Correct |
21 ms |
384 KB |
Output is correct |
93 |
Correct |
19 ms |
384 KB |
Output is correct |
94 |
Correct |
19 ms |
388 KB |
Output is correct |
95 |
Correct |
27 ms |
388 KB |
Output is correct |
96 |
Correct |
21 ms |
388 KB |
Output is correct |
97 |
Correct |
20 ms |
384 KB |
Output is correct |
98 |
Correct |
18 ms |
384 KB |
Output is correct |
99 |
Correct |
19 ms |
384 KB |
Output is correct |
100 |
Correct |
20 ms |
384 KB |
Output is correct |
101 |
Correct |
20 ms |
384 KB |
Output is correct |
102 |
Correct |
17 ms |
384 KB |
Output is correct |
103 |
Correct |
18 ms |
384 KB |
Output is correct |
104 |
Correct |
24 ms |
388 KB |
Output is correct |
105 |
Correct |
19 ms |
384 KB |
Output is correct |
106 |
Correct |
25 ms |
384 KB |
Output is correct |
107 |
Correct |
21 ms |
384 KB |
Output is correct |
108 |
Correct |
18 ms |
384 KB |
Output is correct |
109 |
Correct |
23 ms |
384 KB |
Output is correct |
110 |
Correct |
22 ms |
384 KB |
Output is correct |
111 |
Correct |
22 ms |
384 KB |
Output is correct |
112 |
Correct |
19 ms |
384 KB |
Output is correct |
113 |
Correct |
17 ms |
384 KB |
Output is correct |
114 |
Correct |
23 ms |
384 KB |
Output is correct |
115 |
Correct |
23 ms |
384 KB |
Output is correct |
116 |
Correct |
19 ms |
384 KB |
Output is correct |
117 |
Correct |
18 ms |
384 KB |
Output is correct |
118 |
Correct |
21 ms |
468 KB |
Output is correct |
119 |
Correct |
20 ms |
384 KB |
Output is correct |
120 |
Correct |
784 ms |
656 KB |
Output is correct |
121 |
Correct |
721 ms |
732 KB |
Output is correct |
122 |
Correct |
761 ms |
692 KB |
Output is correct |
123 |
Correct |
741 ms |
740 KB |
Output is correct |
124 |
Correct |
831 ms |
748 KB |
Output is correct |
125 |
Correct |
728 ms |
656 KB |
Output is correct |
126 |
Correct |
744 ms |
760 KB |
Output is correct |
127 |
Correct |
764 ms |
644 KB |
Output is correct |
128 |
Correct |
823 ms |
668 KB |
Output is correct |
129 |
Correct |
784 ms |
736 KB |
Output is correct |
130 |
Correct |
777 ms |
688 KB |
Output is correct |
131 |
Correct |
739 ms |
676 KB |
Output is correct |
132 |
Correct |
856 ms |
540 KB |
Output is correct |
133 |
Correct |
755 ms |
708 KB |
Output is correct |
134 |
Correct |
824 ms |
676 KB |
Output is correct |
135 |
Correct |
740 ms |
660 KB |
Output is correct |
136 |
Correct |
732 ms |
564 KB |
Output is correct |
137 |
Correct |
739 ms |
776 KB |
Output is correct |
138 |
Correct |
803 ms |
692 KB |
Output is correct |
139 |
Correct |
799 ms |
592 KB |
Output is correct |
140 |
Correct |
792 ms |
660 KB |
Output is correct |
141 |
Correct |
727 ms |
620 KB |
Output is correct |
142 |
Correct |
740 ms |
836 KB |
Output is correct |
143 |
Correct |
756 ms |
600 KB |
Output is correct |
144 |
Correct |
858 ms |
600 KB |
Output is correct |
145 |
Correct |
791 ms |
732 KB |
Output is correct |
146 |
Correct |
731 ms |
508 KB |
Output is correct |
147 |
Correct |
731 ms |
688 KB |
Output is correct |
148 |
Correct |
765 ms |
584 KB |
Output is correct |
149 |
Correct |
733 ms |
556 KB |
Output is correct |
150 |
Correct |
731 ms |
656 KB |
Output is correct |
151 |
Correct |
720 ms |
580 KB |
Output is correct |
152 |
Correct |
756 ms |
620 KB |
Output is correct |
153 |
Correct |
734 ms |
592 KB |
Output is correct |
154 |
Correct |
720 ms |
648 KB |
Output is correct |
155 |
Correct |
787 ms |
760 KB |
Output is correct |
156 |
Correct |
773 ms |
652 KB |
Output is correct |
157 |
Correct |
788 ms |
716 KB |
Output is correct |
158 |
Correct |
768 ms |
764 KB |
Output is correct |
159 |
Correct |
758 ms |
600 KB |
Output is correct |
160 |
Correct |
723 ms |
624 KB |
Output is correct |
161 |
Correct |
727 ms |
588 KB |
Output is correct |
162 |
Correct |
802 ms |
768 KB |
Output is correct |
163 |
Correct |
850 ms |
656 KB |
Output is correct |
164 |
Correct |
729 ms |
580 KB |
Output is correct |
165 |
Correct |
723 ms |
556 KB |
Output is correct |
166 |
Correct |
797 ms |
604 KB |
Output is correct |
167 |
Correct |
735 ms |
620 KB |
Output is correct |
168 |
Correct |
757 ms |
640 KB |
Output is correct |
169 |
Correct |
758 ms |
816 KB |
Output is correct |
170 |
Correct |
795 ms |
656 KB |
Output is correct |
171 |
Correct |
860 ms |
676 KB |
Output is correct |
172 |
Correct |
792 ms |
660 KB |
Output is correct |
173 |
Correct |
738 ms |
496 KB |
Output is correct |
174 |
Correct |
873 ms |
608 KB |
Output is correct |
175 |
Correct |
745 ms |
620 KB |
Output is correct |
176 |
Correct |
824 ms |
688 KB |
Output is correct |
177 |
Correct |
752 ms |
680 KB |
Output is correct |
178 |
Correct |
742 ms |
608 KB |
Output is correct |
179 |
Correct |
787 ms |
624 KB |
Output is correct |
180 |
Correct |
778 ms |
792 KB |
Output is correct |
181 |
Correct |
751 ms |
664 KB |
Output is correct |
182 |
Correct |
738 ms |
676 KB |
Output is correct |
183 |
Correct |
751 ms |
720 KB |
Output is correct |
184 |
Correct |
786 ms |
712 KB |
Output is correct |
185 |
Correct |
775 ms |
716 KB |
Output is correct |
186 |
Correct |
800 ms |
668 KB |
Output is correct |
187 |
Correct |
809 ms |
524 KB |
Output is correct |
188 |
Correct |
745 ms |
652 KB |
Output is correct |
189 |
Correct |
806 ms |
492 KB |
Output is correct |
190 |
Correct |
754 ms |
632 KB |
Output is correct |
191 |
Correct |
775 ms |
700 KB |
Output is correct |
192 |
Correct |
720 ms |
632 KB |
Output is correct |
193 |
Correct |
740 ms |
524 KB |
Output is correct |
194 |
Correct |
748 ms |
668 KB |
Output is correct |
195 |
Correct |
746 ms |
648 KB |
Output is correct |
196 |
Correct |
738 ms |
532 KB |
Output is correct |
197 |
Correct |
766 ms |
668 KB |
Output is correct |
198 |
Correct |
717 ms |
708 KB |
Output is correct |
199 |
Correct |
752 ms |
500 KB |
Output is correct |
200 |
Correct |
740 ms |
628 KB |
Output is correct |
201 |
Correct |
766 ms |
724 KB |
Output is correct |
202 |
Correct |
753 ms |
596 KB |
Output is correct |
203 |
Correct |
771 ms |
552 KB |
Output is correct |
204 |
Correct |
784 ms |
604 KB |
Output is correct |
205 |
Correct |
742 ms |
652 KB |
Output is correct |
206 |
Correct |
738 ms |
676 KB |
Output is correct |
207 |
Correct |
746 ms |
648 KB |
Output is correct |
208 |
Correct |
841 ms |
780 KB |
Output is correct |
209 |
Correct |
790 ms |
600 KB |
Output is correct |
210 |
Correct |
638 ms |
624 KB |
Output is correct |
211 |
Correct |
623 ms |
552 KB |
Output is correct |
212 |
Correct |
632 ms |
720 KB |
Output is correct |
213 |
Correct |
556 ms |
668 KB |
Output is correct |
214 |
Correct |
553 ms |
708 KB |
Output is correct |
215 |
Correct |
590 ms |
592 KB |
Output is correct |
216 |
Correct |
579 ms |
740 KB |
Output is correct |
217 |
Correct |
560 ms |
636 KB |
Output is correct |
218 |
Correct |
546 ms |
624 KB |
Output is correct |
219 |
Correct |
573 ms |
612 KB |
Output is correct |
220 |
Correct |
569 ms |
604 KB |
Output is correct |
221 |
Correct |
590 ms |
756 KB |
Output is correct |
222 |
Correct |
559 ms |
624 KB |
Output is correct |
223 |
Correct |
676 ms |
596 KB |
Output is correct |
224 |
Correct |
567 ms |
640 KB |
Output is correct |
225 |
Correct |
609 ms |
668 KB |
Output is correct |
226 |
Correct |
584 ms |
584 KB |
Output is correct |