# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
217248 | 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;
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)){
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;
}
}
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(mx+1);
mx=mx+1;
e+=2;
}
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)
# | 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... |