Submission #217318

#TimeUsernameProblemLanguageResultExecution timeMemory
217318jurichhh8Konstrukcija (COCI20_konstrukcija)C++14
50 / 110
6 ms384 KiB
#include <iostream> #include <cmath> #include <vector> using namespace std; vector<int> veki[1000]; int mx; int main () { long long k; cin>>k; if(k==0){ cout<<5<<" "<<5<<endl<<1<<" "<<2<<endl<<2<<" "<<3<<endl<<2<<" "<<4<<endl<<4<<" "<<5<<endl<<3<<" "<<5; return 0; } int sgn=(k<0); int nep=(k%2); k=abs(k); long long x=log2(k); x++; long long br; if(sgn){ br=k; } else br=pow(2,x)-k; veki[1].push_back(2); veki[1].push_back(3); veki[1].push_back(4); int e=3; for(int i=1;i<x;i++){ veki[3*i-1].push_back(3*i+2); veki[3*i-1].push_back(3*i+3); veki[3*i-1].push_back(3*i+4); veki[3*i].push_back(3*i+2); veki[3*i].push_back(3*i+3); veki[3*i].push_back(3*i+4); veki[3*i+1].push_back(3*i+2); veki[3*i+1].push_back(3*i+3); veki[3*i+1].push_back(3*i+4); e+=9; } br/=2; mx=3*x+2; for(long long i=0;i<x;i++){ if(br & (1<<i)){ if(i%2==0){ veki[1].push_back(mx); veki[mx].push_back(3*(x-i)+1); veki[mx].push_back(3*(x-i)); veki[mx].push_back(3*(x-i)-1); mx++; e+=4; } else{ veki[1].push_back(mx); veki[mx].push_back(3*(x-i)+1); veki[mx].push_back(3*(x-i)); veki[mx].push_back(3*(x-i)-1); mx++; veki[1].push_back(mx); veki[mx].push_back(3*(x-i-1)+1); veki[mx].push_back(3*(x-i-1)); veki[mx].push_back(3*(x-i-1)-1); mx++; e+=8; } } } if(x%2==0){ veki[1].push_back(mx); veki[mx].push_back(2); veki[mx].push_back(3); veki[mx].push_back(4); mx++; e+=4; if(sgn==0){ veki[1].push_back(mx); veki[mx].push_back(2); veki[mx].push_back(3); veki[mx].push_back(4); mx++; e+=4; } } else{ if(sgn){ veki[1].push_back(mx); veki[mx].push_back(2); veki[mx].push_back(3); veki[mx].push_back(4); mx++; e+=4; } } if(nep){ veki[1].push_back(mx); veki[mx].push_back(3*x+1); veki[mx].push_back(3*x-1); veki[mx].push_back(3*x); mx++; veki[1].push_back(mx); veki[mx].push_back(mx+1); mx++; e+=6; } veki[3*x].push_back(mx); veki[3*x-1].push_back(mx); veki[3*x+1].push_back(mx); e+=3; cout<<mx<<" "<<e<<endl; for(int i=1;i<mx;i++){ for(int j=0;j<veki[i].size();j++){ cout<<i<<" "<<veki[i][j]<<endl; } } return 0; }

Compilation message (stderr)

konstrukcija.cpp: In function 'int main()':
konstrukcija.cpp:113:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<veki[i].size();j++){
               ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...