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;
map<int, vector<int> > diag1, diag2;
map<int, pair<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), add_xor(p.second)};
for (auto &p : diag2) rep2[p.first] = {add_or(p.second), add_xor(p.second)};
auto process = [&](map<int, pair<int, int> > &rep, vector<int> &dist_leq, vector<int> &dist_less) {
for (auto &p : rep) {
if (rep.count(p.first + k)) {
vector<int> tmp_or, tmp_xor;
for (int i = p.first; i <= p.first + k; i++) {
tmp_or.push_back(rep[i].first);
tmp_xor.push_back(rep[i].second);
}
dist_leq.push_back(add_xor({add_or(tmp_or), add_xor(tmp_xor)}));
}
if (rep.count(p.first + k - 1)) {
vector<int> tmp_or, tmp_xor;
for (int i = p.first; i <= p.first + k - 1; i++) {
tmp_or.push_back(rep[i].first);
tmp_xor.push_back(rep[i].second);
}
dist_less.push_back(add_xor({add_or(tmp_or), add_xor(tmp_xor)}));
}
}
};
vector<int> dist_leq_1, dist_less_1, dist_leq_2, dist_less_2;
process(rep1, dist_leq_1, dist_less_1); process(rep2, dist_leq_2, dist_less_2);
int leq = add_and({add_or(dist_leq_1), add_or(dist_leq_2)});
int less = add_and({add_or(dist_less_1), add_or(dist_less_2)});
add_xor({leq, less});
}
# | 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... |