# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217074 | jurichhh8 | Konstrukcija (COCI20_konstrukcija) | C++14 | 5 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |