#include "vision.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int h, w, k;
int getPos(int x, int y){
return x*w + y;
}
vector<int>orVertical(){
vector<int>ret;
for(int j = 0 ; j < w ; j ++){
vector<int>positions;
for(int i = 0 ; i < h ; i++){
positions.pb(getPos(i, j));
}
ret.pb(add_or(positions));
}
return ret;
}
vector<int>orHorizontal(){
vector<int>ret;
for(int i = 0 ; i < h ; i ++){
vector<int>positions;
for(int j = 0 ; j < w ; j++){
positions.pb(getPos(i, j));
}
ret.pb(add_or(positions));
}
return ret;
}
int seeAnd(vector<int>ores){
vector<int>ands;
for(int i = 1 ; i < ores.size() ; i ++){
ands.pb(add_and({ores[i-1], ores[i]}));
}
return add_or(ands);
}
void construct_network(int H, int W, int K) {
h = H;
w = W;
k = K;
if(k == 1){
vector<int>orV = orVertical();
int ans1 = add_xor(orV); // 1 si esta a 0 de distancia
vector<int>orH = orHorizontal();
int ans2 = seeAnd(orH); // 1 si esta a uno de distancia
int resultado1 = add_and({ans1, ans2});
ans1 = add_xor(orH);
ans2 = seeAnd(orV);
int resultado2 = add_and({ans1, ans2});
add_or({resultado1, resultado2});
}else if(max(H, W) <= 30 or min(H, W) == 1){
vector<int>todos;
for(int i = 0 ; i < H ; i ++){
for(int j = 0 ; j < W ; j ++){
vector<int>cuales;
for(int xi = 0 ; xi < H ; xi ++){
for(int xj = 0; xj < W ; xj ++){
if(abs(xi-i) + abs(xj-j) == k)cuales.pb(getPos(xi, xj));
}
}
if(cuales.empty()){
continue;
}
int idxOr = add_or(cuales);
todos.pb(add_and({idxOr, getPos(i, j)}));
}
}
add_or(todos);
}else{
vector<int> N;
for(int i = 0 ; i < H ; i ++){
for(int j = 0 ; j < W ; j ++){
if(i + j == k)N.pb(getPos(i, j));
}
}
add_or(N);
}
}
Compilation message
vision.cpp: In function 'int seeAnd(std::vector<int>)':
vision.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i = 1 ; i < ores.size() ; i ++){
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 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 |
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 |
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 |
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 |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1108 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |