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 <vector>
using namespace std;
int _H, _W;
int Get_Index(int x, int y) {
return x * _W + y;
}
void construct_network(int H, int W, int K) {
_H = H;
_W = W;
vector<int> diag[2][H + W - 1];
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
diag[0][i + j].push_back(Get_Index(i, j));
diag[1][i - j + W - 1].push_back(Get_Index(i, j));
}
}
int diagOR[2][H + W - 1];
int diagPref[2][H + W - 1], diagSuf[2][H + W - 1];
int diagEq[2], diagLEQ[2];
for (int d : {0, 1}) {
for (int i = 0; i < H + W - 1; i++) {
diagOR[d][i] = add_or(diag[d][i]);
}
diagPref[d][0] = diagOR[d][0];
for (int i = 1; i < H + W - 1; i++) {
diagPref[d][i] = add_or({diagPref[d][i - 1], diagOR[d][i]});
}
diagSuf[d][H + W - 2] = diagOR[d][H + W - 2];
for (int i = H + W - 3; i >= 0; i--) {
diagSuf[d][i] = add_or({diagSuf[d][i + 1], diagOR[d][i]});
}
vector<int> tmp;
for (int i = 0; i + K < H + W - 1; i++) {
tmp.push_back(add_and({diagOR[d][i], diagOR[d][i + K]}));
}
diagEq[d] = add_or(tmp);
tmp.clear();
if (W + H - 1 > K + 1) {
tmp.push_back(diagPref[d][H + W - 3 - K]);
tmp.push_back(diagSuf[d][K + 1]);
}
for (int i = 1; i + K + 1 < W + H - 1; i++) {
tmp.push_back(add_or({diagPref[d][i - 1], diagSuf[d][i + K + 1]}));
}
if (tmp.empty()) {
diagLEQ[d] = diagPref[d][W + H - 2];
} else {
diagLEQ[d] = add_not(add_and(tmp));
}
//tmp.clear();
}
add_or({
add_and({diagEq[0], diagLEQ[1]}),
add_and({diagEq[1], diagLEQ[0]})
});
}
# | 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... |