#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-0+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-0+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, last3});
}
}
Compilation message
vision.cpp: In function 'int check(int, int, int)':
vision.cpp:25: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]
25 | for(int j=0;j<axy[i].size();j++){
| ~^~~~~~~~~~~~~~
vision.cpp:51: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]
51 | for(int j=0;j<dxy[i].size();j++){
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
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 |
15 ms |
2184 KB |
on inputs (196, 156), (197, 156), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (0, 1), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |