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>
using namespace std;
int h, w, k;
void construct_network(int H, int W, int K) {
h = H; w = W; k = K;
if (k == h + w - 2) {
add_or({add_and({0, h * w - 1}), add_and({w - 1, (h - 1) * w})});
return;
}
map<int, vector<int> > diag1, diag2;
map<int, int> rep1, rep2;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
diag1[i - j].push_back(i * w + j);
diag2[i + j].push_back(i * w + j);
}
}
for (auto &p : diag1) rep1[p.first] = add_or(p.second);
for (auto &p : diag2) rep2[p.first] = add_or(p.second);
vector<int> vx(h + w - 1), vy(h + w - 1);
for (int d = h + w - 2; d >= k; d--) {
vector<int> v1, v2;
for (auto &p : rep1) {
if (p.first >= rep1.begin()->first + d) break;
vector<int> tmp;
for (int i = p.first; ; i += d) {
if (!rep1.count(i)) break;
tmp.push_back(rep1[i]);
}
if ((int) tmp.size() > 1) v1.push_back(add_xor({add_or(tmp), add_xor(tmp)}));
}
vx[d] = add_or(v1);
for (auto &p : rep2) {
if (p.first >= rep2.begin()->first + d) break;
vector<int> tmp;
for (int i = p.first; ; i += d) {
if (!rep2.count(i)) break;
tmp.push_back(rep2[i]);
}
if ((int) tmp.size() > 1) v2.push_back(add_xor({add_or(tmp), add_xor(tmp)}));
}
vy[d] = add_or(v2);
}
vector<int> tmp1, tmp2;
for (int d = h + w - 2; d > k; d--) {
tmp1.push_back(vx[d]);
tmp2.push_back(vy[d]);
}
int a = add_or({add_or(tmp1), add_or(tmp2)});
tmp1.push_back(vx[k]); tmp2.push_back(vy[k]);
int b = add_or({add_or(tmp1), add_or(tmp2)});
add_xor({a, b});
}
# | 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... |