이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+4;
ll k,n,m;
map<ll,vector<int>> anc;
pair<int,int> Ed[N];
int new_1(){ Ed[++m] = {1, ++n};
return n;
}
int Get(ll k){
if (anc.count(k)){ ++n;
for (int x : anc[k]) Ed[++m] = {x, n};
return n;
}
if (k < 0) anc[k] = {Get(-k), Get(-k)};
if (k > 0){
if (k == 1) anc[k] = {new_1(), new_1()};
else{ ll x = k/2;
anc[k] = {Get(-x), Get(-x), Get(-x)};
if (k%2 == 1) anc[k].push_back(new_1());
}
}
return Get(k);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> k; n = 1;
if (k == 0){
cout << "3 2\n1 2\n2 3\n"; return 0;
}
Get(k);
cout << n << " " << m << "\n";
for (int i=1; i<=m; i++)
cout << Ed[i].first << " " << Ed[i].second << "\n";
return 0;
}
//576,460,752,303,423,488
# | 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... |