#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
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 |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1968 KB |
on inputs (96, 130), (143, 84), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |