#include <bits/stdc++.h>
#include "vision.h"
using namespace std;
typedef long long ll;
void construct_network(int h, int w, int k)
{
vector<int> rd1(h + w - 1), rd2(h + w - 1);
vector<int> ld1(h + w - 1), ld2(h + w - 1);
for (int d = 0; d < h + w - 1; d++)
{
// right-diagonal of (i, j) = i + j
vector<int> idx;
for (int i = 0; i < h; i++)
if (0 <= d - i && d - i < w)
idx.push_back(i * w + d - i);
// rd1 : is there at least one black pixel on this diagonal?
rd1[d] = add_or(idx);
// rd2 : are there exactly two black pixels on this diagonal?
rd2[d] = add_xor({add_xor(idx), rd1[d]});
// left-diagonal of (i, j) = i - j + (w - 1)
idx.clear();
for (int i = 0; i < h; i++)
if (0 <= i - d + w - 1 && i - d + w - 1 < w)
idx.push_back(i * w + i - d + w - 1);
// ld1 : is there at least one black pixel on this diagonal?
ld1[d] = add_or(idx);
// ld2 : are there exactly two black pixels on this diagonal?
ld2[d] = add_xor({add_xor(idx), rd1[d]});
}
vector<int> A, B, C, D;
for (int d = 0; d + k < h + w - 1; d++)
{
vector<int> idxR1, idxR2, idxL1, idxL2;
for (int i = 0; i < k + 1; i++)
{
idxR1.push_back(rd1[d + i]);
idxR2.push_back(rd2[d + i]);
idxL1.push_back(ld1[d + i]);
idxL2.push_back(ld2[d + i]);
}
A.push_back(add_or({add_xor({add_or(idxR1), add_xor(idxR1)}),add_or(idxR2)}));
B.push_back(add_or({add_xor({add_or(idxL1), add_xor(idxL1)}),add_or(idxL2)}));
}
for (int d = 0; d + k - 1 < h + w - 1; d++)
{
vector<int> idxR1, idxR2, idxL1, idxL2;
for (int i = 0; i < k; i++)
{
idxR1.push_back(rd1[d + i]);
idxR2.push_back(rd2[d + i]);
idxL1.push_back(ld1[d + i]);
idxL2.push_back(ld2[d + i]);
}
C.push_back(add_or({add_xor({add_or(idxR1), add_xor(idxR1)}),add_or(idxR2)}));
D.push_back(add_or({add_xor({add_or(idxL1), add_xor(idxL1)}),add_or(idxL2)}));
}
int x = add_and({add_or(A), add_or(B)});
int y = add_and({add_or(C), add_or(D)});
add_and({x, add_not(y)});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
724 KB |
Output is correct |
2 |
Correct |
11 ms |
1492 KB |
Output is correct |
3 |
Correct |
12 ms |
1492 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
680 KB |
Output is correct |
6 |
Correct |
12 ms |
1364 KB |
Output is correct |
7 |
Correct |
10 ms |
1320 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
720 KB |
Output is correct |
10 |
Correct |
11 ms |
1336 KB |
Output is correct |
11 |
Correct |
12 ms |
1492 KB |
Output is correct |
12 |
Correct |
13 ms |
1492 KB |
Output is correct |
13 |
Correct |
9 ms |
1236 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
3 ms |
596 KB |
Output is correct |
16 |
Correct |
11 ms |
1316 KB |
Output is correct |
17 |
Correct |
13 ms |
1524 KB |
Output is correct |
18 |
Correct |
12 ms |
1444 KB |
Output is correct |
19 |
Correct |
10 ms |
1108 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
684 KB |
Output is correct |
4 |
Correct |
6 ms |
808 KB |
Output is correct |
5 |
Correct |
7 ms |
936 KB |
Output is correct |
6 |
Correct |
5 ms |
808 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
4 ms |
852 KB |
Output is correct |
9 |
Correct |
11 ms |
1364 KB |
Output is correct |
10 |
Correct |
13 ms |
1492 KB |
Output is correct |
11 |
Correct |
10 ms |
1236 KB |
Output is correct |
12 |
Correct |
3 ms |
592 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
11 ms |
1364 KB |
Output is correct |
15 |
Correct |
10 ms |
1276 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
3 ms |
720 KB |
Output is correct |
18 |
Correct |
12 ms |
1492 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
12 ms |
1568 KB |
Output is correct |
21 |
Correct |
33 ms |
3784 KB |
Output is correct |
22 |
Correct |
29 ms |
3660 KB |
Output is correct |
23 |
Correct |
10 ms |
1236 KB |
Output is correct |
24 |
Correct |
12 ms |
1616 KB |
Output is correct |
25 |
Correct |
34 ms |
4040 KB |
Output is correct |
26 |
Correct |
9 ms |
1236 KB |
Output is correct |
27 |
Incorrect |
3 ms |
1616 KB |
WA in grader: Too many instructions |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1616 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (1, 0), expected 1, but computed 0 |
7 |
Halted |
0 ms |
0 KB |
- |