#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
/*
int add_not(int N)
int add_and(int[] Ns)
int add_or(int[] Ns)
int add_xor(int[] Ns)
*/
int n, m, K;
const int N = 1005;
int st1, end1, st2, end2;
vector <vector <int> > diag1(N), diag2(N);
vector <int> diag1_or(N), diag2_or(N);
vector <int> diag1_xor(N), diag2_xor(N);
vector <int> diag1_duo(N), diag2_duo(N);
int Idx(int A, int B) {
// nums[A][B] = (A-1)*W + B;
return A * m + B;
}
int Dist(int a, int b, int a1, int b1) {
return abs(a-a1)+abs(b-b1);
}
int solve(int k) {
vector <int> pos1;
for (int i = st1; i + k - 1 <= end1; i++) {
vector <int> vals, vals_duo;
for (int j = i; j <= i + k - 1; j++) {
vals.push_back(diag1_or[j]);
vals_duo.push_back(diag1_duo[j]);
}
int a, b, c, d;
a = add_or(vals);
b = add_xor(vals);
c = add_xor({a, b});
d = add_or(vals_duo);
pos1.push_back(add_or({c, d}));
}
int ans1 = pos1.size() == 1 ? pos1[0] : add_or(pos1);
vector <int> pos2;
for (int i = st2; i + k - 1 <= end2; i++) {
vector <int> vals, vals_duo;
for (int j = i; j <= i + k - 1; j++) {
vals.push_back(diag2_or[j]);
vals_duo.push_back(diag2_duo[j]);
}
int a, b, c, d;
a = add_or(vals);
b = add_xor(vals);
c = add_xor({a, b});
d = add_or(vals_duo);
pos2.push_back(add_or({c, d}));
}
int ans2 = pos2.size() == 1 ? pos2[0] : add_or(pos2);
return add_and({ans1, ans2});
}
void construct_network(int H, int W, int K1) {
n = H, m = W, K = K1;
st1 = N, end1 = 0, st2 = N, end2 = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int pos1 = i+j, pos2 = i-j+m, idx = Idx(i, j);
diag1[pos1].push_back(idx);
diag2[pos2].push_back(idx);
st1=min(st1, pos1);
end1=max(end1, pos1);
st2=min(st2, pos2);
end2=max(end2, pos2);
}
}
for (int i = 0; i < N; i++) {
if (diag1[i].size() >= 1) {
diag1_or[i] = diag1[i].size() == 1 ? diag1[i][0] : add_or(diag1[i]);
diag1_xor[i] = diag1[i].size() == 1 ? diag1[i][0] : add_xor(diag1[i]);
diag1_duo[i] = add_xor({diag1_or[i], diag1_xor[i]});
}
if (diag2[i].size() >= 1) {
diag2_or[i] = diag2[i].size() == 1 ? diag2[i][0] : add_or(diag2[i]);
diag2_xor[i] = diag2[i].size() == 1 ? diag2[i][0] : add_xor(diag2[i]);
diag2_duo[i] = add_xor({diag2_or[i], diag2_xor[i]});
}
}
int x = solve(K+1), y = solve(K);
add_xor({x, y});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
3 ms |
460 KB |
Output is correct |
35 |
Correct |
3 ms |
460 KB |
Output is correct |
36 |
Correct |
2 ms |
460 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
3 ms |
460 KB |
Output is correct |
35 |
Correct |
3 ms |
460 KB |
Output is correct |
36 |
Correct |
2 ms |
460 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
20 ms |
1936 KB |
Output is correct |
39 |
Correct |
4 ms |
588 KB |
Output is correct |
40 |
Correct |
5 ms |
512 KB |
Output is correct |
41 |
Correct |
6 ms |
844 KB |
Output is correct |
42 |
Correct |
5 ms |
616 KB |
Output is correct |
43 |
Correct |
9 ms |
1228 KB |
Output is correct |
44 |
Correct |
17 ms |
1948 KB |
Output is correct |
45 |
Correct |
25 ms |
2124 KB |
Output is correct |
46 |
Correct |
19 ms |
1828 KB |
Output is correct |
47 |
Correct |
6 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
716 KB |
Output is correct |
2 |
Correct |
15 ms |
1356 KB |
Output is correct |
3 |
Correct |
15 ms |
1420 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
4 ms |
716 KB |
Output is correct |
6 |
Correct |
14 ms |
1356 KB |
Output is correct |
7 |
Correct |
14 ms |
1272 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
3 ms |
716 KB |
Output is correct |
10 |
Correct |
14 ms |
1228 KB |
Output is correct |
11 |
Correct |
15 ms |
1416 KB |
Output is correct |
12 |
Correct |
16 ms |
1484 KB |
Output is correct |
13 |
Correct |
12 ms |
1100 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
3 ms |
716 KB |
Output is correct |
16 |
Correct |
12 ms |
1228 KB |
Output is correct |
17 |
Correct |
15 ms |
1436 KB |
Output is correct |
18 |
Correct |
22 ms |
1356 KB |
Output is correct |
19 |
Correct |
11 ms |
1100 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
4 ms |
716 KB |
Output is correct |
4 |
Correct |
7 ms |
972 KB |
Output is correct |
5 |
Correct |
9 ms |
1112 KB |
Output is correct |
6 |
Correct |
9 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
460 KB |
Output is correct |
8 |
Correct |
7 ms |
968 KB |
Output is correct |
9 |
Correct |
14 ms |
1476 KB |
Output is correct |
10 |
Correct |
16 ms |
1612 KB |
Output is correct |
11 |
Correct |
13 ms |
1296 KB |
Output is correct |
12 |
Correct |
4 ms |
716 KB |
Output is correct |
13 |
Correct |
4 ms |
716 KB |
Output is correct |
14 |
Correct |
13 ms |
1356 KB |
Output is correct |
15 |
Correct |
14 ms |
1244 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
716 KB |
Output is correct |
18 |
Correct |
15 ms |
1396 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
14 ms |
1896 KB |
Output is correct |
21 |
Correct |
41 ms |
4032 KB |
Output is correct |
22 |
Correct |
40 ms |
3892 KB |
Output is correct |
23 |
Correct |
11 ms |
1484 KB |
Output is correct |
24 |
Correct |
14 ms |
1864 KB |
Output is correct |
25 |
Correct |
45 ms |
4240 KB |
Output is correct |
26 |
Correct |
12 ms |
1488 KB |
Output is correct |
27 |
Incorrect |
4 ms |
2120 KB |
WA in grader: Too many instructions |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2120 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
3 ms |
460 KB |
Output is correct |
29 |
Correct |
2 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
2 ms |
460 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
3 ms |
460 KB |
Output is correct |
35 |
Correct |
3 ms |
460 KB |
Output is correct |
36 |
Correct |
2 ms |
460 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
20 ms |
1936 KB |
Output is correct |
39 |
Correct |
4 ms |
588 KB |
Output is correct |
40 |
Correct |
5 ms |
512 KB |
Output is correct |
41 |
Correct |
6 ms |
844 KB |
Output is correct |
42 |
Correct |
5 ms |
616 KB |
Output is correct |
43 |
Correct |
9 ms |
1228 KB |
Output is correct |
44 |
Correct |
17 ms |
1948 KB |
Output is correct |
45 |
Correct |
25 ms |
2124 KB |
Output is correct |
46 |
Correct |
19 ms |
1828 KB |
Output is correct |
47 |
Correct |
6 ms |
844 KB |
Output is correct |
48 |
Correct |
4 ms |
716 KB |
Output is correct |
49 |
Correct |
15 ms |
1356 KB |
Output is correct |
50 |
Correct |
15 ms |
1420 KB |
Output is correct |
51 |
Correct |
2 ms |
332 KB |
Output is correct |
52 |
Correct |
4 ms |
716 KB |
Output is correct |
53 |
Correct |
14 ms |
1356 KB |
Output is correct |
54 |
Correct |
14 ms |
1272 KB |
Output is correct |
55 |
Correct |
2 ms |
332 KB |
Output is correct |
56 |
Correct |
3 ms |
716 KB |
Output is correct |
57 |
Correct |
14 ms |
1228 KB |
Output is correct |
58 |
Correct |
15 ms |
1416 KB |
Output is correct |
59 |
Correct |
16 ms |
1484 KB |
Output is correct |
60 |
Correct |
12 ms |
1100 KB |
Output is correct |
61 |
Correct |
1 ms |
332 KB |
Output is correct |
62 |
Correct |
3 ms |
716 KB |
Output is correct |
63 |
Correct |
12 ms |
1228 KB |
Output is correct |
64 |
Correct |
15 ms |
1436 KB |
Output is correct |
65 |
Correct |
22 ms |
1356 KB |
Output is correct |
66 |
Correct |
11 ms |
1100 KB |
Output is correct |
67 |
Correct |
1 ms |
332 KB |
Output is correct |
68 |
Correct |
1 ms |
332 KB |
Output is correct |
69 |
Correct |
1 ms |
332 KB |
Output is correct |
70 |
Correct |
1 ms |
332 KB |
Output is correct |
71 |
Correct |
1 ms |
332 KB |
Output is correct |
72 |
Correct |
4 ms |
716 KB |
Output is correct |
73 |
Correct |
7 ms |
972 KB |
Output is correct |
74 |
Correct |
9 ms |
1112 KB |
Output is correct |
75 |
Correct |
9 ms |
844 KB |
Output is correct |
76 |
Correct |
2 ms |
460 KB |
Output is correct |
77 |
Correct |
7 ms |
968 KB |
Output is correct |
78 |
Correct |
14 ms |
1476 KB |
Output is correct |
79 |
Correct |
16 ms |
1612 KB |
Output is correct |
80 |
Correct |
13 ms |
1296 KB |
Output is correct |
81 |
Correct |
4 ms |
716 KB |
Output is correct |
82 |
Correct |
4 ms |
716 KB |
Output is correct |
83 |
Correct |
13 ms |
1356 KB |
Output is correct |
84 |
Correct |
14 ms |
1244 KB |
Output is correct |
85 |
Correct |
2 ms |
332 KB |
Output is correct |
86 |
Correct |
3 ms |
716 KB |
Output is correct |
87 |
Correct |
15 ms |
1396 KB |
Output is correct |
88 |
Correct |
2 ms |
332 KB |
Output is correct |
89 |
Correct |
14 ms |
1896 KB |
Output is correct |
90 |
Correct |
41 ms |
4032 KB |
Output is correct |
91 |
Correct |
40 ms |
3892 KB |
Output is correct |
92 |
Correct |
11 ms |
1484 KB |
Output is correct |
93 |
Correct |
14 ms |
1864 KB |
Output is correct |
94 |
Correct |
45 ms |
4240 KB |
Output is correct |
95 |
Correct |
12 ms |
1488 KB |
Output is correct |
96 |
Incorrect |
4 ms |
2120 KB |
WA in grader: Too many instructions |
97 |
Halted |
0 ms |
0 KB |
- |