This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "vision.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
using namespace std;
int dp1or[405], dp1xor[405];
int dp2or[405], dp2xor[405];
void construct_network(int H, int W, int K) {
for(int key = 0; key <= H+W-2; key++) {
vector<int> V;
for(int i = 0, j = key; i < H; i++, j--)
if(0 <= j && j < W) V.eb(i*W + j);
dp1or[key] = 1 == sz(V) ? V[0] : add_or(V);
dp1xor[key] = 1 == sz(V) ? V[0] : add_xor(V);
V.clear();
for(int i = 0, j = key-H+1; i < H; i++, j++)
if(0 <= j && j < W) V.eb(i*W + j);
dp2or[key] = 1 == sz(V) ? V[0] : add_or(V);
dp2xor[key] = 1 == sz(V) ? V[0] : add_xor(V);
}
auto make = [&]() -> int {
vector<int> AV, OV;
for(int i = K; i <= H+W-2; i++)
AV.eb(add_and({dp1or[i-K], dp1or[i]}));
for(int i = 0; i < H+W-2; i++) {
vector<int> V;
for(int j = min(i+K, H+W-2); i < j; j--) V.eb(dp2or[j]);
V.eb(add_not(dp2xor[i]));
OV.eb(add_and({dp2or[i], add_or(V)}));
}
return add_and({add_or(AV), add_or(OV)});
};
int ret = make();
for(int i = 0; i < 405; i++) {
swap(dp1or[i], dp2or[i]);
swap(dp1xor[i], dp2xor[i]);
}
add_or({ret, make()});
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |