Submission #147136

#TimeUsernameProblemLanguageResultExecution timeMemory
147136Mamnoon_SiamVision Program (IOI19_vision)C++17
100 / 100
16 ms1652 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; const int maxn = 202; int H, W, K; int one, zero; int cell(int i, int j) { return i * W + j; } void construct_network(int _H, int _W, int _K) { H = _H, W = _W, K = _K; if(H * W == 2) { one = 0; zero = add_not(one); } else { zero = add_and({0, 1, 2}); one = add_not(zero); } vector<int> R_prefix, C_prefix; { int prev = zero; for(int i = 0; i < H - 1; i++) { vector<int> tmp; for(int j = 0; j < W; j++) { tmp.emplace_back(cell(i, j)); } tmp.emplace_back(prev); R_prefix.emplace_back(add_xor(tmp)); prev = R_prefix.back(); } R_prefix.emplace_back(zero); } { int prev = zero; for(int j = 0; j < W - 1; j++) { vector<int> tmp; for(int i = 0; i < H; i++) { tmp.emplace_back(cell(i, j)); } tmp.emplace_back(prev); C_prefix.emplace_back(add_xor(tmp)); prev = C_prefix.back(); } C_prefix.emplace_back(zero); } vector<int> tot; for(int i = 0; i < H - 1; i++) { vector<int> tmp; int carry = R_prefix[i]; for(int j = 0; j < tot.size(); j++) { tmp.emplace_back(add_xor({carry, tot[j]})); carry = add_and({carry, tot[j]}); } if(tmp.size() < 32 - __builtin_clz(i + 1)) tmp.emplace_back(carry); tot = tmp; } for(int i = 0; i < W - 1; i++) { vector<int> tmp; int carry = C_prefix[i]; for(int j = 0; j < tot.size(); j++) { tmp.emplace_back(add_xor({carry, tot[j]})); carry = add_and({carry, tot[j]}); } if(tmp.size() < 32 - __builtin_clz(H + i)) tmp.emplace_back(carry); tot = tmp; } vector<int> allzero, allone; for(int i = 0; i < tot.size(); i++) { if(K & (1 << i)) { allzero.emplace_back(add_xor({one, tot[i]})); } else { allzero.emplace_back(add_xor({zero, tot[i]})); } } for(int i = 0; i < allzero.size(); i++) { allone.emplace_back(add_not(allzero[i])); } add_and(allone); }

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:55:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < tot.size(); j++) {
                  ~~^~~~~~~~~~~~
vision.cpp:59:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(tmp.size() < 32 - __builtin_clz(i + 1))
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
vision.cpp:66:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < tot.size(); j++) {
                  ~~^~~~~~~~~~~~
vision.cpp:70:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(tmp.size() < 32 - __builtin_clz(H + i))
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
vision.cpp:76:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < tot.size(); i++) {
                 ~~^~~~~~~~~~~~
vision.cpp:83:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < allzero.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...