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>
using namespace std;
int add_not(int n);
int add_and(vector<int> ns);
int add_or(vector<int> ns);
int add_xor(vector<int> ns);
int getpoint(int x, int y, int w){
return x*w + y;
}
int check(int h, int w, int k){
vector<int> aans, dans;
vector<pair<int, int> > axy[402], dxy[402];
int aidx[402], didx[402];
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
axy[i+j].push_back(make_pair(i, j));
dxy[i-j+200].push_back(make_pair(i, j));
}
}
vector<int> p3;
for(int i=0;i<h+w;i++){
vector<int> p2;
for(int j=0;j<axy[i].size();j++){
int p = getpoint(axy[i][j].first, axy[i][j].second, w);
p2.push_back(p);
}
if(p2.empty()) continue;
aidx[i] = add_or(p2);
p3.push_back(aidx[i]);
}
int acheck = add_xor(p3);
for(int i=0;i<h+w;i++){
vector<int> p2;
for(int j=0;j<h+w;j++){
if(i == j) continue;
if(abs(i-j) <= k) p2.push_back(aidx[j]);
}
if(p2.empty()) continue;
p2.push_back(acheck);
int tmp = add_or(p2);
aans.push_back(add_and(vector<int>{aidx[i], tmp}));
}
int ans1 = add_or(aans);
p3.clear();
for(int i=0-w+200;i<h-w+200;i++){
vector<int> p2;
for(int j=0;j<dxy[i].size();j++){
int p = getpoint(dxy[i][j].first, dxy[i][j].second, w);
p2.push_back(p);
}
if(p2.empty()) continue;
didx[i] = add_or(p2);
p3.push_back(didx[i]);
}
int dcheck = add_xor(p3);
for(int i=0-w+200;i<h-w+200;i++){
vector<int> p2;
for(int j=0-w+200;j<h-w+200;j++){
if(i == j) continue;
if(abs(i-j) <= k) p2.push_back(didx[j]);
}
if(p2.empty()) continue;
p2.push_back(dcheck);
int tmp = add_or(p2);
dans.push_back(add_and(vector<int>{didx[i], tmp}));
}
int ans2 = add_or(dans);
return add_and(vector<int>{ans1, ans2});
}
void construct_network(int h, int w, int k){
int last1 = check(h, w, k);
if(k != 1){
int last2 = check(h, w, k-1);
int last3 = add_not(last2);
add_and(vector<int>{last1, last2});
}
}
Compilation message (stderr)
vision.cpp: In function 'int check(int, int, int)':
vision.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int j=0;j<axy[i].size();j++){
| ~^~~~~~~~~~~~~~
vision.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int j=0;j<dxy[i].size();j++){
| ~^~~~~~~~~~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:79:13: warning: unused variable 'last3' [-Wunused-variable]
79 | int last3 = add_not(last2);
| ^~~~~
# | 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... |