#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
bool limites(int x, int y, int h, int w){
return x>=0&&x<h&&y>=0&&y<w;
}
void construct_network(int H, int W, int K) {
map<pair<int,int>,int>numero;
int pos=0;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
numero[{i,j}]=pos;
pos++;
}
}
vector<int>dx,dy;
for(int restar=0;restar<=K;restar++){
int c_x=restar;
int c_y=K-restar;
dx.push_back(c_x);
dy.push_back(c_y);
dx.push_back(-c_x);
dy.push_back(c_y);
dx.push_back(c_x);
dy.push_back(-c_y);
dx.push_back(-c_x);
dy.push_back(-c_y);
}
map<pair<pair<int,int>,pair<int,int>>,bool>marked;
int cnt=1;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
for(int itr=0;itr<dx.size();itr++){
int x=i+dx[itr];
int y=j+dy[itr];
if(limites(x,y,H,W)){
if(!marked[{{i,j},{x,y}}]&&!marked[{{x,y},{i,j}}]){
add_and({numero[{i,j}],numero[{x,y}]});
cnt++;
marked[{{i,j},{x,y}}]=true;
}
}
}
}
}
vector<int>instruct;
for(int i=H*W;i<=(H*W+cnt-1);i++){
instruct.push_back(i);
}
add_or(instruct);
}
Compilation message
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int itr=0;itr<dx.size();itr++){
| ~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
4816 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |