Submission #201617

#TimeUsernameProblemLanguageResultExecution timeMemory
201617khulegubVision Program (IOI19_vision)C++14
0 / 100
30 ms2152 KiB
#include "vision.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define rr first #define cc second using namespace std; typedef pair<int, int> pii; int hh, ww, kk; pii to_pair(int x){ return mp(x / ww, x % ww); } int to_linear(pii x){ return x.rr * ww + x.cc; } void construct_network(int H, int W, int K) { // proj y hh = H, ww = W, kk = K; int carry; int one = add_or( {0, 1} ), zero = add_not(one); vector<int> proj_hor; for (int i = 0; i < ww; i++){ vector<int> send; for (int j = 0; j < hh; j++){ send.pb(to_linear(mp(i, j))); } proj_hor.pb(add_or(send)); } for (int i = 0; i < ww; i++){ vector<int> send; for (int j = 0; j <= i; j++){ send.pb(proj_hor[j]); } proj_hor[i] = add_xor(send); } // vector<int> proj_ver; for (int i = 0; i < hh; i++){ vector<int> send; for (int j = 0; j < ww; j++){ send.pb(to_linear(mp(j, i))); } proj_ver.pb(add_or(send)); } for (int i = 0; i < hh; i++){ vector<int> send; for (int j = 0; j <= i; j++){ send.pb(proj_ver[j]); } proj_ver[i] = add_xor(send); } // // max val = h + w // // log_2 (400) + 1 = 9 int bitlen = 10; vector<int> counter; // initialize for (int i = 0; i < bitlen; i++){ counter.pb(add_and({zero, 0})); } for (int j = 0; j < ww; j++){ int adder = proj_hor[j]; for (int i = 0; i < bitlen; i++){ int tmp = counter[i]; counter[i] = add_xor({counter[i], adder}); adder = add_and({tmp, adder}); } } for (int j = 0; j < hh; j++){ int adder = proj_ver[j]; for (int i = 0; i < bitlen; i++){ int tmp = counter[i]; counter[i] = add_xor({counter[i], adder}); adder = add_and({tmp, adder}); } } kk = kk + 2; int last = one; vector<int> kkbits; for (int i = 0; i < bitlen; i++){ kkbits.pb(kk % 2); kk /= 2; } for (int i = 0; i < bitlen; i++){ if (kkbits[i]){ last = add_and({last, counter[i]}); } else{ last = add_and({last, add_not(counter[i]) }); } } }

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:26:6: warning: unused variable 'carry' [-Wunused-variable]
  int carry;
      ^~~~~
#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...