#include <bits/stdc++.h>
#include "vision.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<int>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
const int MOD = 1e9 + 7;
int H, W;
map<int, int> A[2], B[2];
int calc(int x, int y) {
return x * W + y;
}
int dist(int x, int y, int X, int Y) {
return abs(x - X) + abs(y - Y);
}
int solve(int K) {
vector<int> U, V;
for(int l = -(H + W); l < (H + W); l++) {
if(l + K - 1 < H + W) {
vector<int> X, Y;
for(int i = l; i < l + K; i++)
X.push_back(A[i][0]), Y.push_back(A[i][1]);
int C = add_xor({add_or(X), add_xor(X)});
Y.push_back(C); U.push_back(add_or(Y));
}
}
for(int l = 0; l < H + W; l++) {
if(l + K - 1 < H + W) {
vector<int> X, Y;
for(int i = l; i < l + K; i++)
X.push_back(B[i][0]), Y.push_back(B[i][1]);
int C = add_xor({add_or(X), add_xor(X)});
Y.push_back(C); V.push_back(add_or(Y));
}
}
return add_and({add_or(U), add_or(V)});
}
void construct_network(int h, int w, int K) {
H = h, ::W = w;
for(int l = -(H + W); l < (H + W); l++) {
vector<int> V;
for(int i = 0; i < H; i++) {
for(int j = 0; j < W; j++) {
if(i - j != l) continue;
V.push_back(calc(i, j));
}
}
if(V.empty()) continue;
A[l][0] = add_or(V);
A[l][1] = add_xor({A[l][0], add_xor(V)});
}
for(int l = 0; l < (H + W); l++) {
vector<int> V;
for(int i = 0; i < H; i++) {
for(int j = 0; j < W; j++) {
if(i + j != l) continue;
V.push_back(calc(i, j));
}
}
if(V.empty()) continue;
B[l][0] = add_or(V);
B[l][1] = add_xor({B[l][0], add_xor(V)});
}
add_and({solve(K + 1), add_not(solve(K))});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |