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;
vector<int> rdiag[405];
vector<int> ldiag[405];
int rdiagxor[405];
int ldiagxor[405];
int rdiagor[405];
int ldiagor[405];
int h,w;
int test(int dist){
//printf("test dist %d\n",dist);
vector<int> retl;
for (int i = 0; i < h+w-1; i++){
vector<int> X;
vector<int> O;
for (int j = 0; j <= dist; j++){
if (i+j > h+w-2) continue;
X.push_back(ldiagxor[i+j]);
O.push_back(ldiagor[i+j]);
}
//printf("adding range [%d-%d]\n",i,i+dist);
retl.push_back(add_and({add_or(O), add_not(add_xor(X))}));
}
//printf("ldiag done\n");
vector<int> retr;
for (int i = 0; i < h+w-1; i++){
vector<int> X;
vector<int> O;
for (int j = 0; j <= dist; j++){
if (i+j > h+w-2) continue;
X.push_back(rdiagxor[i+j]);
O.push_back(rdiagor[i+j]);
}
//printf("adding range [%d-%d]\n",i,i+dist);
retr.push_back(add_and({add_or(O), add_not(add_xor(X))}));
}
//printf("rdiag done\n");
//printf("test dist %d: retl %d, retr %d\n",dist,retl.size(),retr.size());
return add_and({add_or(retl), add_or(retr)});
}
void construct_network(int H, int W, int K) {
h = H, w = W;
for (int i = 0; i < H; i++){
for (int j = 0; j < W; j++){
ldiag[i+j].push_back(i*W+j);
rdiag[H-1-i+j].push_back(i*W+j);
}
}
for (int i = 0; i < H+W; i++){
if (ldiag[i].size()) ldiagxor[i] = add_xor(ldiag[i]);
if (ldiag[i].size()) ldiagor[i] = add_or(ldiag[i]);
if (rdiag[i].size()) rdiagxor[i] = add_xor(rdiag[i]);
if (rdiag[i].size()) rdiagor[i] = add_or(rdiag[i]);
}
//printf("start test\n");
add_and({test(K), add_not(test(K-1))});
}
# | 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... |