Submission #795938

#TimeUsernameProblemLanguageResultExecution timeMemory
795938APROHACKVision Program (IOI19_vision)C++17
66 / 100
10 ms1108 KiB
#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(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 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{ 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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...