Submission #217074

#TimeUsernameProblemLanguageResultExecution timeMemory
217074jurichhh8Konstrukcija (COCI20_konstrukcija)C++14
0 / 110
5 ms384 KiB
#include <iostream> #include <cmath> #include <vector> using namespace std; vector<int> veki[1000]; int mx; void dfs(int br,long long k){ if(k==0ll) return; int next=br+1; if(k%2==1){ veki[1].push_back(next); veki[next].push_back(br); next++; k--; mx=next; } if(k==0) return; if(k==2){ veki[1].push_back(next); veki[next].push_back(br); veki[1].push_back(next+1); veki[next+1].push_back(br); mx=next+2; } else{ veki[next].push_back(br); veki[next+1].push_back(br); veki[next+2].push_back(next); veki[next+2].push_back(next+1); dfs(next+2,k/2ll); } } int main () { long long k; cin>>k; if(k==0ll){ cout<<1<<" "<<2<<endl; cout<<2<<" "<<3<<endl; cout<<1<<" "<<3<<endl; return 0; } dfs(2,abs(k)); veki[2].push_back(mx); veki[mx].push_back(mx+1); if(k<0){ veki[mx+1].push_back(mx+2); } for(int i=1;i<=mx+1;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:53: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...