#include "vision.h"
#include <bits/stdc++.h>
#ifdef __LOCAL__
#include <debug_local.h>
#endif
using namespace std;
void construct_network(int H, int W, int K) {
vector<int> posleft(H + W), posxorleft(H + W);
for (int diag = 0; diag <= H + W - 2; diag++) {
vector<int> v;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (i + j == diag) {
v.push_back(i * W + j);
}
}
}
posleft[diag] = add_or(v);
posxorleft[diag] = add_xor(v);
}
vector<int> posright(H + W), posxorright(H + W);
for (int diag = 0; diag <= H + W - 2; diag++) {
vector<int> v;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (j - i + H - 1 == diag) {
v.push_back(i * W + j);
}
}
}
posright[diag] = add_or(v);
posxorright[diag] = add_xor(v);
}
vector<int> hastwoleft(H + W);
for (int diag = 0; diag <= H + W - 2; diag++) {
vector<int> v1, v2;
for (int d = diag; d <= min(H + W - 2, diag + 2 * K + 1); d++) {
v1.push_back(posleft[d]);
v2.push_back(posxorleft[d]);
}
int orr = add_or(v1);
int xorr = add_xor(v2);
hastwoleft[diag] = add_and({orr, add_not(xorr)});
}
vector<int> hastworight(H + W);
for (int diag = 0; diag <= H + W - 2; diag++) {
vector<int> v1, v2;
for (int d = diag; d <= min(H + W - 2, diag + 2 * K + 1); d++) {
v1.push_back(posright[d]);
v2.push_back(posxorright[d]);
}
int orr = add_or(v1);
int xorr = add_xor(v2);
hastworight[diag] = add_and({orr, add_not(xorr)});
}
vector<int> twodiagleft(H + W);
for (int diag = 0; diag <= H + W - 2 - K; diag++) {
twodiagleft[diag] = add_and({posleft[diag], posleft[diag + K]});
}
vector<int> twodiagright(H + W);
for (int diag = 0; diag <= H + W - 2 - K; diag++) {
twodiagright[diag] = add_and({posright[diag], posright[diag + K]});
}
int first;
{
vector<int> v;
for (int diag = 0; diag <= H + W - 2 - K; diag++) {
v.push_back(twodiagleft[diag]);
}
int f1 = add_or(v);
v.clear();
for (int diag = 0; diag <= H + W - 2; diag++) {
v.push_back(hastworight[diag]);
}
int f2 = add_or(v);
first = add_and({f1, f2});
}
int second;
{
vector<int> v;
for (int diag = 0; diag <= H + W - 2 - K; diag++) {
v.push_back(twodiagright[diag]);
}
int f1 = add_or(v);
v.clear();
for (int diag = 0; diag <= H + W - 2; diag++) {
v.push_back(hastwoleft[diag]);
}
int f2 = add_or(v);
second = add_and({f1, f2});
}
add_or({first, second});
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
468 KB |
Output is correct |
2 |
Correct |
8 ms |
1108 KB |
Output is correct |
3 |
Correct |
10 ms |
1108 KB |
Output is correct |
4 |
Correct |
12 ms |
1108 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
8 ms |
980 KB |
Output is correct |
7 |
Correct |
8 ms |
1108 KB |
Output is correct |
8 |
Correct |
8 ms |
1108 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
7 ms |
1044 KB |
Output is correct |
11 |
Correct |
8 ms |
1108 KB |
Output is correct |
12 |
Correct |
8 ms |
1152 KB |
Output is correct |
13 |
Correct |
8 ms |
1108 KB |
Output is correct |
14 |
Correct |
8 ms |
1108 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
7 ms |
968 KB |
Output is correct |
17 |
Correct |
9 ms |
1052 KB |
Output is correct |
18 |
Correct |
8 ms |
1108 KB |
Output is correct |
19 |
Correct |
9 ms |
1108 KB |
Output is correct |
20 |
Correct |
8 ms |
1108 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
468 KB |
Output is correct |
4 |
Correct |
5 ms |
728 KB |
Output is correct |
5 |
Correct |
6 ms |
744 KB |
Output is correct |
6 |
Correct |
6 ms |
724 KB |
Output is correct |
7 |
Correct |
6 ms |
724 KB |
Output is correct |
8 |
Correct |
5 ms |
656 KB |
Output is correct |
9 |
Correct |
9 ms |
1108 KB |
Output is correct |
10 |
Correct |
10 ms |
1236 KB |
Output is correct |
11 |
Correct |
11 ms |
1280 KB |
Output is correct |
12 |
Correct |
10 ms |
1236 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
8 ms |
980 KB |
Output is correct |
15 |
Correct |
8 ms |
1036 KB |
Output is correct |
16 |
Correct |
8 ms |
1108 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
8 ms |
1108 KB |
Output is correct |
19 |
Correct |
9 ms |
1108 KB |
Output is correct |
20 |
Correct |
15 ms |
1380 KB |
Output is correct |
21 |
Correct |
33 ms |
2892 KB |
Output is correct |
22 |
Correct |
30 ms |
3016 KB |
Output is correct |
23 |
Correct |
30 ms |
3072 KB |
Output is correct |
24 |
Correct |
15 ms |
1360 KB |
Output is correct |
25 |
Correct |
31 ms |
3044 KB |
Output is correct |
26 |
Correct |
29 ms |
3020 KB |
Output is correct |
27 |
Correct |
32 ms |
2256 KB |
Output is correct |
28 |
Correct |
52 ms |
4564 KB |
Output is correct |
29 |
Correct |
60 ms |
5324 KB |
Output is correct |
30 |
Correct |
62 ms |
5384 KB |
Output is correct |
31 |
Correct |
58 ms |
5320 KB |
Output is correct |
32 |
Correct |
0 ms |
300 KB |
Output is correct |
33 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
31 ms |
2208 KB |
on inputs (57, 107), (59, 108), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 2), (1, 0), expected 0, but computed 1 |
8 |
Halted |
0 ms |
0 KB |
- |