Submission #778690

#TimeUsernameProblemLanguageResultExecution timeMemory
778690jasminVision Program (IOI19_vision)C++17
52 / 100
2 ms468 KiB
#include "vision.h" #include<bits/stdc++.h> using namespace std; int ind(int x, int y, int H, int W){ assert(0<=x && x<H && 0<=y && y<W); return x*W + y; } bool valid(int x, int y, int H, int W){ return (0<=x && x<H && 0<=y && y<W); } void construct_network_small(int H, int W, int K) { vector<int> ns_ans; int cnt=0; for(int x=0; x<H; x++){ for(int y=0; y<W; y++){ vector<int> ns; for(int i=0; i<=K; i++){ int x2=x+i; int y2=y-(K-i); if(valid(x2, y2, H, W)){ ns.push_back(ind(x2, y2, H, W)); } y2=y+(K-i); if(valid(x2, y2, H, W)){ ns.push_back(ind(x2, y2, H, W)); } } if(!ns.empty()){ add_or(ns); cnt++; add_and({ind(x, y, H, W), H*W + cnt-1}); cnt++; ns_ans.push_back(H*W + cnt-1); } } } add_or({ns_ans}); } void construct_network_zero(int H, int W, int K){ int x=0; int y=0; vector<int> ns; for(int i=0; i<=K; i++){ int x2=x+i; int y2=y-(K-i); if(valid(x2, y2, H, W)){ ns.push_back(ind(x2, y2, H, W)); } y2=y+(K-i); if(valid(x2, y2, H, W)){ ns.push_back(ind(x2, y2, H, W)); } } int i=add_or(ns); add_and({0, i}); } void construct_network1(int H, int W, int K){ vector<int> orh(H); for(int i=0; i<H; i++){ vector<int> ns; for(int j=0; j<W; j++){ ns.push_back(i*W + j); } orh[i] = add_or(ns); } int samelineh = add_xor(orh); vector<int> orw(W); for(int j=0; j<W; j++){ vector<int> ns; for(int i=0; i<H; i++){ ns.push_back(i*W + j); } orw[j] = add_or(ns); } int samelinew = add_xor(orw); vector<int> andh(H); for(int i=0; i+1<H; i++){ andh[i] = add_and({orh[i], orh[i+1]}); } int neighboursh = add_or(andh); vector<int> andw(W); for(int i=0; i+1<W; i++){ andw[i] = add_and({orw[i], orw[i+1]}); } int neighboursw = add_or(andw); int ans = add_or({add_and({samelineh, neighboursw}), add_and({samelinew, neighboursh})}); } void construct_network(int H, int W, int K){ if(H*W<=1000){ construct_network_small(H, W, K); return; } /*if(K==1){ construct_network1(H, W, K); return; }*/ construct_network_zero(H, W, K); }

Compilation message (stderr)

vision.cpp: In function 'void construct_network1(int, int, int)':
vision.cpp:116:9: warning: unused variable 'ans' [-Wunused-variable]
  116 |     int ans = add_or({add_and({samelineh, neighboursw}), add_and({samelinew, neighboursh})});
      |         ^~~
#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...