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 <bits/stdc++.h>
#include "vision.h"
using namespace std;
void construct_network(int H, int W, int K) {
vector<int> row;
vector<int> col;
for (int i = 0; i < H * W; i++) col.push_back(i % W), row.push_back(i / W);
vector<vector<int>> maindiag(H + W - 1);
for (int i = 0; i < H * W; i++) maindiag[col[i] + row[i]].push_back(i);
int sz = H * W;
for (int i = 0; i < H + W - 1; i++) {
add_or(maindiag[i]);
sz++;
}
int start = sz;
for (int i = 0; i < H + W - 1 - K; i++) {
vector<int> inp;
inp.push_back(H * W + i);
inp.push_back(H * W + i + K);
add_and(inp);
sz++;
}
vector<int> maink;
for (int i = start; i < start + H + W - 1 - K; i++) maink.push_back(i);
add_or(maink);
int KFIRST = sz;
sz++;
vector<int> morek;
for (int i = 0; i < H + W - 1 - K - 1; i++) {
vector<int> inp1;
for (int j = i + K + 1; j < H + W - 1; j++) inp1.push_back(H * W + j);
add_or(inp1);
sz++;
vector<int> inp2;
inp2.push_back(H * W + i);
inp2.push_back(sz - 1);
add_and(inp2);
morek.push_back(sz);
sz++;
}
add_or(morek);
add_not(sz);
sz++;
int LKFIRST = sz;
sz++;
vector<vector<int>> otherdiag(H + W - 1);
for (int i = 0; i < H * W; i++) otherdiag[W - 1 - col[i] + row[i]].push_back(i);
int start2 = sz;
for (int i = 0; i < H + W - 1; i++) {
add_or(otherdiag[i]);
sz++;
}
start = sz;
for (int i = 0; i < H + W - 1 - K; i++) {
vector<int> inp;
inp.push_back(start2 + i);
inp.push_back(start2 + i + K);
add_and(inp);
sz++;
}
vector<int> otherk;
for (int i = start; i < start + H + W - 1 - K; i++) otherk.push_back(i);
add_or(otherk);
int KSECOND = sz;
sz++;
vector<int> moreok;
for (int i = 0; i < H + W - 1 - K - 1; i++) {
vector<int> inp1;
for (int j = i + K + 1; j < H + W - 1; j++) inp1.push_back(start2 + j);
add_or(inp1);
sz++;
vector<int> inp2;
inp2.push_back(start2 + i);
inp2.push_back(sz - 1);
add_and(inp2);
moreok.push_back(sz);
sz++;
}
add_or(moreok);
add_not(sz);
sz++;
int LKSECOND = sz;
sz++;
add_and({KFIRST, LKSECOND});
add_and({LKFIRST, KSECOND});
add_or({sz, sz + 1});
sz += 3;
}
# | 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... |