제출 #217075

#제출 시각아이디문제언어결과실행 시간메모리
217075jurichhh8Konstrukcija (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<<3<<" "<<3<<endl; 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); mx=mx+1; } int edg=0; for(int i=1;i<=mx;i++){ edg+=veki[i].size(); } cout<<mx+1<<" "<<edg<<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; }

컴파일 시 표준 에러 (stderr) 메시지

konstrukcija.cpp: In function 'int main()':
konstrukcija.cpp:60: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...