Submission #227158

#TimeUsernameProblemLanguageResultExecution timeMemory
227158kshitij_sodaniKonstrukcija (COCI20_konstrukcija)C++17
110 / 110
6 ms384 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef int64_t llo; #define mp make_pair #define pb push_back #define a first #define b second #define endl "\n" int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); llo k; cin>>k; if(k==0){ cout<<3<<" "<<2<<endl; cout<<1<<" "<<2<<endl; cout<<2<<" "<<3<<endl; return 0; } llo st=0; llo prod=1; vector<llo> ex; vector<vector<llo>> ac; ac.pb({1}); llo ind=2; llo pre[61]; pre[0]=1; for(llo i=1;i<61;i++){ pre[i]=pre[i-1]*2; } int stt=0; if(k<0){ k=-k; stt=1; } // cout<<pre[54]<<endl; for(llo i=60;i>=0;i--){ // cout<<(llo)(1<<i)<<endl; llo acc=(pre[i]&k); if(acc==(llo)0){ if(st==0){ continue; } else{ ac.pb({ind,ind+1,ind+2}); ind+=3; prod*=-2; } } else{ if(st==0){ st=1; } else{ //ac.pb({ind,ind+1,ind+2}); //prod*=2; if(prod<0){ ac.pb({ind,ind+1}); ind+=2; prod*=-1; } ac.pb({ind,ind+1,ind+2,ind+3}); ind+=4; prod*=-2; prod-=1; } } } if(prod==k){ ac.pb({ind,ind+1}); ind+=2; } if(stt==1){ ac.pb({ind,ind+1}); ind+=2; } ac.pb({ind}); ind+=1; vector<pair<llo,llo>> ans; for(llo i=1;i<ac.size();i++){ for(llo j=0;j<min((llo)3,(llo)ac[i].size());j++){ for(auto k:ac[i-1]){ ans.pb({k,ac[i][j]}); } } if(ac[i].size()==4){ ans.pb({1,ac[i][3]}); } } if(ind-1>1000 or ans.size()>1000){ while(true){ continue; } } cout<<ind-1<<" "<<ans.size()<<endl; for(auto j:ans){ cout<<j.a<<" "<<j.b<<endl; } return 0; }

Compilation message (stderr)

konstrukcija.cpp: In function 'int main()':
konstrukcija.cpp:89:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(llo i=1;i<ac.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...