Submission #146206

#TimeUsernameProblemLanguageResultExecution timeMemory
146206m3r8Vision Program (IOI19_vision)C++14
100 / 100
37 ms3704 KiB
#include "vision.h" #include <vector> #include <algorithm> int posT(int x, int y, int w){ return x*w+y; }; void construct_network(int H, int W, int K) { std::vector<int> orDig; std::vector<int> xrDig; std::vector<int> olDig; std::vector<int> xlDig; std::vector<int> dig; int xD,yD; for(int i = 0;i<H;i++){ dig.clear(); xD = i; yD = 0; while(xD >= 0 && yD < W){ dig.push_back(posT(xD,yD,W)); xD--; yD++; }; orDig.push_back(add_or(dig)); xrDig.push_back(add_xor(dig)); dig.clear(); xD = i; yD = W-1; while(xD >= 0 && yD >=0){ dig.push_back(posT(xD,yD,W)); xD--; yD--; }; olDig.push_back(add_or(dig)); xlDig.push_back(add_xor(dig)); }; for(int i = 0;i<W;i++){ dig.clear(); yD = i; xD = H-1; if(i){ while(xD >= 0 && yD < W){ dig.push_back(posT(xD,yD,W)); xD--; yD++; }; orDig.push_back(add_or(dig)); xrDig.push_back(add_xor(dig)); dig.clear(); }; yD = i; xD = H-1; if(i < W-1){ while(xD >= 0 && yD >= 0){ dig.push_back(posT(xD,yD,W)); xD--; yD--; }; olDig.push_back(add_or(dig)); xlDig.push_back(add_xor(dig)); dig.clear(); }; }; std::reverse(olDig.begin()+H,olDig.end()); std::reverse(xlDig.begin()+H,xlDig.end()); std::reverse(olDig.begin(),olDig.end()); std::reverse(xlDig.begin(),xlDig.end()); std::vector<int> rAnd; std::vector<int> lAnd; for(int i = 0;i<orDig.size()-K;i++){ rAnd.push_back(add_and({orDig[i],orDig[i+K]})); lAnd.push_back(add_and({olDig[i],olDig[i+K]})); //printf("%d %d\n",olDig[i],olDig[i+K]); }; std::vector<int> dxr; std::vector<int> dxl; std::vector<int> dor; std::vector<int> dol; for(int i = 0;i<orDig.size()-K;i++){ std::vector<int> akt1; std::vector<int> akt2; std::vector<int> akt3; std::vector<int> akt4; for(int j = i;j<=i+K;j++){ akt1.push_back(orDig[j]); akt2.push_back(xrDig[j]); akt3.push_back(olDig[j]); akt4.push_back(xlDig[j]); }; dxr.push_back(add_xor(akt2)); dxl.push_back(add_xor(akt4)); dor.push_back(add_or(akt1)); dol.push_back(add_or(akt3)); }; std::vector<int> rr; std::vector<int> rl; for(int i = 0;i<dxr.size();i++){ rr.push_back(add_not(dxr[i])); rl.push_back(add_not(dxl[i])); }; std::vector<int> adr; std::vector<int> adl; for(int i = 0;i<rr.size();i++){ adr.push_back(add_and({rr[i],dor[i]})); adl.push_back(add_and({rl[i],dol[i]})); }; int orr = add_or(rAnd); int orl = add_or(lAnd); int arr = add_or(adr); int arl = add_or(adl); int ad1 = add_and({orr,arl}); int ad2 = add_and({orl,arr}); add_or({ad1,ad2}); }

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:72:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i<orDig.size()-K;i++){
                 ~^~~~~~~~~~~~~~~
vision.cpp:81:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i<orDig.size()-K;i++){
                 ~^~~~~~~~~~~~~~~
vision.cpp:99:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i<dxr.size();i++){
                 ~^~~~~~~~~~~
vision.cpp:105:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0;i<rr.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...