#include "vision.h"
#ifdef NYAOWO
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i,a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
// #define int LL
using namespace std;
using LL = long long;
using pii = pair<int, int>;
const int MAXN = 410;
const int MAXLG = 10;
vector<vector<int>> dia1; // x + y, [0, H + W - 2]
vector<vector<int>> dia2; // x - y + W - 1, [0, H + W - 2]
int xor1[MAXN], xor2[MAXN];
int or1[MAXN][MAXLG], or2[MAXN][MAXLG];
int check(int k) {
int lg = __lg(k + 1);
int k2 = 1 << lg;
int n = sz(dia1);
if(k == 0) return xor1[n - 1];
// cout << "\n";
// cout << lg << " " << k2 << "\n";
vector<int> v;
For(i, 0, n - k - 1) {
// cout << i << " " << i + k << "\n";
// or = 1, xor = 0 => 2 black cells
v.eb(add_xor({
add_or({or1[i][lg], or1[i + k - k2 + 1][lg]}),
(i > 0 ? add_xor({xor1[i], xor1[i + k + 1]}) : xor1[i + k + 1])
}));
}
int a = add_or(v);
v.clear();
For(i, 0, n - k - 1) {
// or = 1, xor = 0 => 2 black cells
v.eb(add_xor({
add_or({or2[i][lg], or2[i + k - k2 + 1][lg]}),
(i > 0 ? add_xor({xor2[i], xor2[i + k + 1]}) : xor2[i + k + 1])
}));
}
int b = add_or(v);
// cout << "output: " << a << " " << b << "\n";
return add_and({a, b});
}
void construct_network(int H, int W, int K) {
// std::vector<int> Ns;
// Ns = {0, 1};
// int a = add_and(Ns);
// Ns = {0, a};
// int b = add_or(Ns);
// Ns = {0, 1, b};
// int c = add_xor(Ns);
// add_not(c);
int n = H + W - 1;
dia1.resize(n);
dia2.resize(n);
For(i, 0, H - 1) For(j, 0, W - 1) {
int id = i * W + j;
dia1[i + j].eb(id);
dia2[i - j + W - 1].eb(id);
}
For(i, 0, n - 1) {
if(i) dia1[i].eb(xor1[i]);
xor1[i + 1] = add_xor(dia1[i]);
if(i) dia1[i].pop_back();
if(i) dia2[i].eb(xor2[i]);
xor2[i + 1] = add_xor(dia2[i]);
if(i) dia2[i].pop_back();
}
Forr(i, n - 1, 0) {
or1[i][0] = add_or(dia1[i]);
or2[i][0] = add_or(dia2[i]);
For(j, 0, MAXLG - 2) {
or1[i][j + 1] = or1[i][j];
or2[i][j + 1] = or2[i][j];
if(i + (1 << j) < n) {
or1[i][j + 1] = add_or({or1[i][j], or1[i + (1 << j)][j]});
or2[i][j + 1] = add_or({or2[i][j], or2[i + (1 << j)][j]});
}
}
}
int a = check(K);
int b = check(K - 1);
b = add_not(b);
add_and({a, b});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (0, 2), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (0, 2), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (0, 2), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (0, 2), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
724 KB |
on inputs (0, 197), (0, 198), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
4 ms |
692 KB |
Output is correct |
4 |
Correct |
3 ms |
724 KB |
Output is correct |
5 |
Correct |
3 ms |
596 KB |
Output is correct |
6 |
Correct |
3 ms |
684 KB |
Output is correct |
7 |
Correct |
3 ms |
596 KB |
Output is correct |
8 |
Correct |
5 ms |
852 KB |
Output is correct |
9 |
Correct |
5 ms |
944 KB |
Output is correct |
10 |
Correct |
4 ms |
852 KB |
Output is correct |
11 |
Correct |
4 ms |
852 KB |
Output is correct |
12 |
Correct |
4 ms |
852 KB |
Output is correct |
13 |
Correct |
3 ms |
688 KB |
Output is correct |
14 |
Correct |
3 ms |
692 KB |
Output is correct |
15 |
Correct |
3 ms |
688 KB |
Output is correct |
16 |
Correct |
2 ms |
596 KB |
Output is correct |
17 |
Correct |
4 ms |
724 KB |
Output is correct |
18 |
Correct |
3 ms |
724 KB |
Output is correct |
19 |
Correct |
2 ms |
720 KB |
Output is correct |
20 |
Correct |
11 ms |
1840 KB |
Output is correct |
21 |
Correct |
11 ms |
1872 KB |
Output is correct |
22 |
Correct |
11 ms |
1792 KB |
Output is correct |
23 |
Correct |
11 ms |
1708 KB |
Output is correct |
24 |
Correct |
11 ms |
1872 KB |
Output is correct |
25 |
Correct |
11 ms |
1872 KB |
Output is correct |
26 |
Correct |
11 ms |
1744 KB |
Output is correct |
27 |
Incorrect |
3 ms |
2220 KB |
WA in grader: Too many instructions |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2128 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 1), (0, 2), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |