#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;
const ll MAXN = 500;
vll wh1[MAXN], wh2[MAXN];
void construct_network (int h, int w, int k) {
auto toLine = [&](ll i, ll j) { return 0 <= i && i < h && 0 <= j && j < w ? i*w+j : -16; };
for (ll i = 0; i < h; i++) {
for (ll j = 0; j < w; j++) {
wh1[i+j].push_back(toLine(i, j));
wh2[j+h-1-i].push_back(toLine(i, j));
}
}
vi diag1, diag2;
for (ll i = 0; i < h+w-1; i++) {
diag1.push_back(add_or(vi(wh1[i].begin(), wh1[i].end())));
diag2.push_back(add_or(vi(wh2[i].begin(), wh2[i].end())));
}
vi op1, op2;
// or op1: dis in diag1 == k
// or op2: dis in diag2 == k
for (ll i = k; i < h+w-1; i++) {
op1.push_back(add_and({ diag1[i-k], diag1[i] }));
op2.push_back(add_and({ diag2[i-k], diag2[i] }));
}
vi bd1, bd2;
// or bd1: dis in diag1 > k
// or bd2: dis in diag2 > k
for (ll i = k; i < h+w-1 - 1; i++) {
ll p1 = i-k+1, p2 = i;
bd1.push_back(add_and({ add_or(vi(diag1.begin(), diag1.begin()+p1-1+1)), add_or(vi(diag1.begin()+p2+1, diag1.end())) }));
bd2.push_back(add_and({ add_or(vi(diag2.begin(), diag2.begin()+p1-1+1)), add_or(vi(diag2.begin()+p2+1, diag2.end())) }));
}
add_and({ add_not({ add_or(bd1) }), add_not({ add_or(bd2) }), add_or({ add_or(op1), add_or(op2) }) });
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
5460 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
860 KB |
Output is correct |
4 |
Correct |
4 ms |
1372 KB |
Output is correct |
5 |
Correct |
5 ms |
1112 KB |
Output is correct |
6 |
Correct |
4 ms |
1116 KB |
Output is correct |
7 |
Correct |
11 ms |
3164 KB |
Output is correct |
8 |
Correct |
11 ms |
3164 KB |
Output is correct |
9 |
Correct |
29 ms |
5456 KB |
Output is correct |
10 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |