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;
void construct_network(int H, int W, int K) {
vector <int> sum[2000],diff[2000];
int idxsum[2000],idxdiff[2000];
for (int i=0; i<H; i++){
for (int j=0; j<W; j++){
sum[i+j].push_back(i*W+j);
diff[i-j+1000].push_back(i*W+j);
}
}
for (int i=0; i<2000; i++){
if (sum[i].empty()) idxsum[i]=-1;
else idxsum[i]=add_or(sum[i]);
}
for (int i=0; i<2000; i++){
if (diff[i].empty()) idxdiff[i]=-1;
else idxdiff[i]=add_or(diff[i]);
}
vector <int> possible;
for (int i=0; i<2000; i++){
if (idxsum[i]==-1) continue;
vector <int> v;
for (int j=i+K; j<2000; j++){
if (idxsum[j]!=-1) v.push_back(idxsum[j]);
}
if (v.empty()) continue;
int tp=add_or(v);
v.clear();
v.push_back(idxsum[i]); v.push_back(tp);
possible.push_back(add_and(v));
}
for (int i=0; i<2000; i++){
if (idxdiff[i]==-1) continue;
vector <int> v;
for (int j=i+K; j<2000; j++){
if (idxdiff[j]!=-1) v.push_back(idxdiff[j]);
}
if (v.empty()) continue;
int tp=add_or(v);
v.clear();
v.push_back(idxdiff[i]); v.push_back(tp);
possible.push_back(add_and(v));
}
int have=add_or(possible);
possible.clear();
K++;
for (int i=0; i<2000; i++){
if (idxsum[i]==-1) continue;
vector <int> v;
for (int j=i+K; j<2000; j++){
if (idxsum[j]!=-1) v.push_back(idxsum[j]);
}
if (v.empty()) continue;
int tp=add_or(v);
v.clear();
v.push_back(idxsum[i]); v.push_back(tp);
possible.push_back(add_and(v));
}
for (int i=0; i<2000; i++){
if (idxdiff[i]==-1) continue;
vector <int> v;
for (int j=i+K; j<2000; j++){
if (idxdiff[j]!=-1) v.push_back(idxdiff[j]);
}
if (v.empty()) continue;
int tp=add_or(v);
v.clear();
v.push_back(idxdiff[i]); v.push_back(tp);
possible.push_back(add_and(v));
}
if (possible.empty()){
vector <int> v;
v.push_back(have);
add_and(v);
return;
}
int haveadd=add_or(possible);
haveadd=add_not(haveadd);
{
vector <int> v;
v.push_back(have); v.push_back(haveadd);
add_and(v);
}
}
# | 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... |