#include "vision.h"
#include <bits/stdc++.h>
#define X first
#define Y second
#define MP make_pair
#define ll long long
using namespace std;
const int N = 300;
void build(int n, int (&arr)[N], const int (&mem)[N]){
for(int it = 0;(1 << it) < n;it++){
vector< int > fin;
for(int i1 = 0;i1 + 1 < n;i1++){
vector<int> tmp;
for(int i2 = i1 + 1;i2 < n;i2++){
if(((i2 - i1) >> it) & 1){
tmp.push_back(mem[i2]);
}
}
if(tmp.empty()) continue;
int v = add_xor(tmp);
v = add_and({mem[i1], v});
fin.push_back(v);
}
arr[it] = add_or(fin);
}
}
int prep(int len, int n, const int (&arr)[N]){
int v;
if(len == 0){
vector<int> tmp;
for(int i = 0;i < n;i++){
tmp.push_back(arr[i]);
}
v = add_xor(tmp);
}
else{
vector<int> tmp1, tmp2;
for(int i = 0;(1 << i) < n;i++){
if((len >> i) & 1) tmp1.push_back(arr[i]);
else tmp2.push_back(arr[i]);
}
if(tmp1.empty()){
v = add_not(add_or(tmp2));
}
else if(tmp2.empty()){
v = add_and(tmp1);
}
else{
v = add_and({add_and(tmp1), add_not(add_or(tmp2))});
}
}
return v;
}
int isRow[N], isCol[N];
int bRow[N], bCol[N];
void construct_network(int H, int W, int K) {
for(int i = 0;i < H;i++){
vector<int> tmp;
for(int j = 0;j < W;j++){
tmp.push_back(W * i + j);
}
isRow[i] = add_or(tmp);
}
for(int j = 0;j < W;j++){
vector<int> tmp;
for(int i = 0;i < H;i++){
tmp.push_back(W * i + j);
}
isCol[j] = add_or(tmp);
}
build(H, bRow, isRow);
build(W, bCol, isCol);
vector< int > fin;
for(int i = 0;i < H;i++){
for(int j = 0;j < W;j++){
if(i + j == K){
int x = prep(i, H, i == 0 ? isRow: bRow);
int y = prep(j, W, j == 0 ? isCol: bCol);
fin.push_back(add_and({x, y}));
}
}
}
add_or(fin);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
252 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
2 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
252 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
2 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
204 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 |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
2 ms |
332 KB |
Output is correct |
35 |
Correct |
2 ms |
332 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
252 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
2 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
204 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 |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
2 ms |
332 KB |
Output is correct |
35 |
Correct |
2 ms |
332 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
8 ms |
940 KB |
Output is correct |
39 |
Correct |
3 ms |
460 KB |
Output is correct |
40 |
Correct |
4 ms |
460 KB |
Output is correct |
41 |
Correct |
5 ms |
588 KB |
Output is correct |
42 |
Correct |
5 ms |
548 KB |
Output is correct |
43 |
Correct |
8 ms |
972 KB |
Output is correct |
44 |
Correct |
8 ms |
932 KB |
Output is correct |
45 |
Correct |
8 ms |
972 KB |
Output is correct |
46 |
Correct |
8 ms |
972 KB |
Output is correct |
47 |
Correct |
11 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
996 KB |
Output is correct |
2 |
Correct |
13 ms |
1004 KB |
Output is correct |
3 |
Correct |
12 ms |
916 KB |
Output is correct |
4 |
Correct |
9 ms |
972 KB |
Output is correct |
5 |
Correct |
11 ms |
932 KB |
Output is correct |
6 |
Correct |
13 ms |
972 KB |
Output is correct |
7 |
Correct |
13 ms |
972 KB |
Output is correct |
8 |
Correct |
13 ms |
972 KB |
Output is correct |
9 |
Correct |
14 ms |
972 KB |
Output is correct |
10 |
Correct |
13 ms |
972 KB |
Output is correct |
11 |
Correct |
10 ms |
1016 KB |
Output is correct |
12 |
Correct |
10 ms |
972 KB |
Output is correct |
13 |
Correct |
12 ms |
1028 KB |
Output is correct |
14 |
Correct |
9 ms |
972 KB |
Output is correct |
15 |
Correct |
13 ms |
996 KB |
Output is correct |
16 |
Correct |
10 ms |
968 KB |
Output is correct |
17 |
Correct |
12 ms |
1036 KB |
Output is correct |
18 |
Correct |
10 ms |
972 KB |
Output is correct |
19 |
Correct |
12 ms |
972 KB |
Output is correct |
20 |
Correct |
14 ms |
944 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
236 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
588 KB |
Output is correct |
4 |
Correct |
6 ms |
588 KB |
Output is correct |
5 |
Correct |
4 ms |
640 KB |
Output is correct |
6 |
Correct |
4 ms |
540 KB |
Output is correct |
7 |
Correct |
4 ms |
576 KB |
Output is correct |
8 |
Correct |
7 ms |
888 KB |
Output is correct |
9 |
Correct |
7 ms |
864 KB |
Output is correct |
10 |
Correct |
13 ms |
884 KB |
Output is correct |
11 |
Correct |
10 ms |
844 KB |
Output is correct |
12 |
Correct |
7 ms |
844 KB |
Output is correct |
13 |
Correct |
10 ms |
972 KB |
Output is correct |
14 |
Correct |
10 ms |
972 KB |
Output is correct |
15 |
Correct |
10 ms |
972 KB |
Output is correct |
16 |
Correct |
13 ms |
972 KB |
Output is correct |
17 |
Correct |
10 ms |
972 KB |
Output is correct |
18 |
Correct |
14 ms |
1004 KB |
Output is correct |
19 |
Correct |
11 ms |
972 KB |
Output is correct |
20 |
Correct |
18 ms |
1668 KB |
Output is correct |
21 |
Correct |
21 ms |
1860 KB |
Output is correct |
22 |
Correct |
22 ms |
1844 KB |
Output is correct |
23 |
Correct |
19 ms |
1672 KB |
Output is correct |
24 |
Correct |
17 ms |
1740 KB |
Output is correct |
25 |
Correct |
20 ms |
1736 KB |
Output is correct |
26 |
Correct |
17 ms |
1736 KB |
Output is correct |
27 |
Correct |
37 ms |
2748 KB |
Output is correct |
28 |
Correct |
39 ms |
2788 KB |
Output is correct |
29 |
Correct |
30 ms |
2868 KB |
Output is correct |
30 |
Correct |
38 ms |
2840 KB |
Output is correct |
31 |
Correct |
38 ms |
2696 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
2752 KB |
Output is correct |
2 |
Correct |
1 ms |
224 KB |
Output is correct |
3 |
Correct |
5 ms |
588 KB |
Output is correct |
4 |
Correct |
10 ms |
872 KB |
Output is correct |
5 |
Correct |
13 ms |
1036 KB |
Output is correct |
6 |
Correct |
13 ms |
1008 KB |
Output is correct |
7 |
Correct |
22 ms |
1736 KB |
Output is correct |
8 |
Correct |
17 ms |
1692 KB |
Output is correct |
9 |
Correct |
36 ms |
2700 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
252 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
2 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
204 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 |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
2 ms |
332 KB |
Output is correct |
35 |
Correct |
2 ms |
332 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
8 ms |
940 KB |
Output is correct |
39 |
Correct |
3 ms |
460 KB |
Output is correct |
40 |
Correct |
4 ms |
460 KB |
Output is correct |
41 |
Correct |
5 ms |
588 KB |
Output is correct |
42 |
Correct |
5 ms |
548 KB |
Output is correct |
43 |
Correct |
8 ms |
972 KB |
Output is correct |
44 |
Correct |
8 ms |
932 KB |
Output is correct |
45 |
Correct |
8 ms |
972 KB |
Output is correct |
46 |
Correct |
8 ms |
972 KB |
Output is correct |
47 |
Correct |
11 ms |
972 KB |
Output is correct |
48 |
Correct |
13 ms |
996 KB |
Output is correct |
49 |
Correct |
13 ms |
1004 KB |
Output is correct |
50 |
Correct |
12 ms |
916 KB |
Output is correct |
51 |
Correct |
9 ms |
972 KB |
Output is correct |
52 |
Correct |
11 ms |
932 KB |
Output is correct |
53 |
Correct |
13 ms |
972 KB |
Output is correct |
54 |
Correct |
13 ms |
972 KB |
Output is correct |
55 |
Correct |
13 ms |
972 KB |
Output is correct |
56 |
Correct |
14 ms |
972 KB |
Output is correct |
57 |
Correct |
13 ms |
972 KB |
Output is correct |
58 |
Correct |
10 ms |
1016 KB |
Output is correct |
59 |
Correct |
10 ms |
972 KB |
Output is correct |
60 |
Correct |
12 ms |
1028 KB |
Output is correct |
61 |
Correct |
9 ms |
972 KB |
Output is correct |
62 |
Correct |
13 ms |
996 KB |
Output is correct |
63 |
Correct |
10 ms |
968 KB |
Output is correct |
64 |
Correct |
12 ms |
1036 KB |
Output is correct |
65 |
Correct |
10 ms |
972 KB |
Output is correct |
66 |
Correct |
12 ms |
972 KB |
Output is correct |
67 |
Correct |
14 ms |
944 KB |
Output is correct |
68 |
Correct |
1 ms |
204 KB |
Output is correct |
69 |
Correct |
0 ms |
292 KB |
Output is correct |
70 |
Correct |
0 ms |
236 KB |
Output is correct |
71 |
Correct |
1 ms |
204 KB |
Output is correct |
72 |
Correct |
4 ms |
588 KB |
Output is correct |
73 |
Correct |
6 ms |
588 KB |
Output is correct |
74 |
Correct |
4 ms |
640 KB |
Output is correct |
75 |
Correct |
4 ms |
540 KB |
Output is correct |
76 |
Correct |
4 ms |
576 KB |
Output is correct |
77 |
Correct |
7 ms |
888 KB |
Output is correct |
78 |
Correct |
7 ms |
864 KB |
Output is correct |
79 |
Correct |
13 ms |
884 KB |
Output is correct |
80 |
Correct |
10 ms |
844 KB |
Output is correct |
81 |
Correct |
7 ms |
844 KB |
Output is correct |
82 |
Correct |
10 ms |
972 KB |
Output is correct |
83 |
Correct |
10 ms |
972 KB |
Output is correct |
84 |
Correct |
10 ms |
972 KB |
Output is correct |
85 |
Correct |
13 ms |
972 KB |
Output is correct |
86 |
Correct |
10 ms |
972 KB |
Output is correct |
87 |
Correct |
14 ms |
1004 KB |
Output is correct |
88 |
Correct |
11 ms |
972 KB |
Output is correct |
89 |
Correct |
18 ms |
1668 KB |
Output is correct |
90 |
Correct |
21 ms |
1860 KB |
Output is correct |
91 |
Correct |
22 ms |
1844 KB |
Output is correct |
92 |
Correct |
19 ms |
1672 KB |
Output is correct |
93 |
Correct |
17 ms |
1740 KB |
Output is correct |
94 |
Correct |
20 ms |
1736 KB |
Output is correct |
95 |
Correct |
17 ms |
1736 KB |
Output is correct |
96 |
Correct |
37 ms |
2748 KB |
Output is correct |
97 |
Correct |
39 ms |
2788 KB |
Output is correct |
98 |
Correct |
30 ms |
2868 KB |
Output is correct |
99 |
Correct |
38 ms |
2840 KB |
Output is correct |
100 |
Correct |
38 ms |
2696 KB |
Output is correct |
101 |
Correct |
1 ms |
204 KB |
Output is correct |
102 |
Correct |
1 ms |
204 KB |
Output is correct |
103 |
Correct |
30 ms |
2752 KB |
Output is correct |
104 |
Correct |
1 ms |
224 KB |
Output is correct |
105 |
Correct |
5 ms |
588 KB |
Output is correct |
106 |
Correct |
10 ms |
872 KB |
Output is correct |
107 |
Correct |
13 ms |
1036 KB |
Output is correct |
108 |
Correct |
13 ms |
1008 KB |
Output is correct |
109 |
Correct |
22 ms |
1736 KB |
Output is correct |
110 |
Correct |
17 ms |
1692 KB |
Output is correct |
111 |
Correct |
36 ms |
2700 KB |
Output is correct |
112 |
Correct |
1 ms |
204 KB |
Output is correct |
113 |
Correct |
1 ms |
204 KB |
Output is correct |
114 |
Correct |
37 ms |
2848 KB |
Output is correct |
115 |
Correct |
12 ms |
988 KB |
Output is correct |
116 |
Correct |
10 ms |
936 KB |
Output is correct |
117 |
Correct |
23 ms |
1800 KB |
Output is correct |
118 |
Correct |
19 ms |
1728 KB |
Output is correct |
119 |
Correct |
34 ms |
2808 KB |
Output is correct |
120 |
Correct |
40 ms |
2820 KB |
Output is correct |
121 |
Correct |
37 ms |
2864 KB |
Output is correct |
122 |
Correct |
40 ms |
2956 KB |
Output is correct |
123 |
Correct |
33 ms |
2680 KB |
Output is correct |
124 |
Correct |
32 ms |
2772 KB |
Output is correct |
125 |
Correct |
31 ms |
2916 KB |
Output is correct |
126 |
Correct |
34 ms |
2888 KB |
Output is correct |
127 |
Correct |
34 ms |
2788 KB |
Output is correct |
128 |
Correct |
35 ms |
2748 KB |
Output is correct |