#include <bits/stdc++.h>
#include "vision.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
void construct_network(int H, int W, int K) {
vi ups;
for (int y = 0; y < W; y++) {
pi st = mp(0, y);
vi diag;
while (st.f < H && st.s < W) {
diag.pb(W * st.f + st.s);
++st.f, ++st.s;
}
ups.pb(add_and({add_or(diag), add_xor(diag)}));
}
for (int x = 1; x < H; x++) {
pi st = mp(x, 0);
vi diag;
while (st.f < H && st.s < W) {
diag.pb(W * st.f + st.s);
++st.f, ++st.s;
}
ups.pb(add_and({add_or(diag), add_xor(diag)}));
}
vi downs;
for (int y = 0; y < W; y++) {
pi st = mp(0, y);
vi diag;
while (st.f >= 0 && st.s >= 0) {
diag.pb(W * st.f + st.s);
--st.f, --st.s;
}
downs.pb(add_and({add_or(diag), add_xor(diag)}));
}
for (int x = 1; x < H; x++) {
pi st = mp(x, W - 1);
vi diag;
while (st.f >= 0 && st.s >= 0) {
diag.pb(W * st.f + st.s);
--st.f, --st.s;
}
downs.pb(add_and({add_or(diag), add_xor(diag)}));
}
vi psup(sz(ups));
for (int i = 0; i < sz(ups); i++) {
if (i == 0) {
psup[i] = add_xor({ups[i]});
}
else {
psup[i] = add_xor({ups[i], psup[i - 1]});
}
}
vi pdown(sz(downs));
for (int i = 0; i < sz(downs); i++) {
if (i == 0) {
pdown[i] = add_xor({downs[i]});
}
else {
pdown[i] = add_xor({downs[i], pdown[i - 1]});
}
}
int upok = -1, downok = -1;
for (int i = 0; i < sz(ups) - K; i++) {
vi curr;
for (int j = i; j < i + K; j++) {
curr.pb(psup[j]);
}
if (i == 0) upok = add_and(curr);
else upok = add_or({upok, add_and(curr)});
}
for (int i = 0; i < sz(downs) - K; i++) {
vi curr;
for (int j = i; j < i + K; j++) {
curr.pb(pdown[j]);
}
if (i == 0) downok = add_and(curr);
else downok = add_or({downok, add_and(curr)});
}
int NK = K + 1;
int upok2 = -1, downok2 = -1;
for (int i = 0; i < sz(ups) - NK; i++) {
vi curr;
for (int j = i; j < i + NK; j++) {
curr.pb(psup[j]);
}
if (i == 0) upok2 = add_and(curr);
else upok2 = add_or({upok2, add_and(curr)});
}
for (int i = 0; i < sz(downs) - NK; i++) {
vi curr;
for (int j = i; j < i + NK; j++) {
curr.pb(pdown[j]);
}
if (i == 0) downok2 = add_and(curr);
else downok2 = add_or({downok2, add_and(curr)});
}
if (W + H - 2 == K) {
add_or({upok, downok});
}
else {
add_and({add_or({upok, downok}), add_not(add_or({upok2, downok2}))});
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Incorrect |
1 ms |
256 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Incorrect |
1 ms |
256 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Incorrect |
1 ms |
256 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Incorrect |
1 ms |
256 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
640 KB |
Output is correct |
2 |
Correct |
6 ms |
896 KB |
Output is correct |
3 |
Correct |
7 ms |
896 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
640 KB |
Output is correct |
6 |
Correct |
6 ms |
768 KB |
Output is correct |
7 |
Correct |
7 ms |
896 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
6 ms |
768 KB |
Output is correct |
11 |
Correct |
7 ms |
896 KB |
Output is correct |
12 |
Correct |
7 ms |
896 KB |
Output is correct |
13 |
Correct |
5 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
640 KB |
Output is correct |
16 |
Correct |
6 ms |
768 KB |
Output is correct |
17 |
Correct |
7 ms |
896 KB |
Output is correct |
18 |
Correct |
7 ms |
896 KB |
Output is correct |
19 |
Correct |
5 ms |
768 KB |
Output is correct |
20 |
Correct |
2 ms |
416 KB |
Output is correct |
21 |
Correct |
1 ms |
256 KB |
Output is correct |
22 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
1916 KB |
on inputs (126, 120), (176, 169), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Incorrect |
1 ms |
256 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
6 |
Halted |
0 ms |
0 KB |
- |