#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, sign, curSign;
ll k;
vector<int> lastLayer;
vector<pair<int, int>> edges;
void AddLayer(int sz){
vector<int> nxtLayer;
for(int i = 1; i <= sz; i++)
nxtLayer.push_back(++n);
for(int u : lastLayer)
for(int v : nxtLayer)
edges.push_back({u, v});
curSign *= -1;
lastLayer = nxtLayer;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> k;
if (k == 0){
cout << "3 2\n";
cout << "1 2\n";
cout << "2 3\n";
return 0;
} else if (k < 0){
sign = -1;
k = -k;
} else {
sign = 1;
k = k;
}
n = 1, curSign = -1;
lastLayer = {1};
int p = 0;
for(int i = 0; i < 60; i++)
if ((k >> i) & 1)
p = i;
for(int i = p - 1; i >= 0; i--)
AddLayer(3 + ((k >> i) & 1));
if (curSign != sign)
AddLayer(2);
AddLayer(1);
cout << n << ' ' << edges.size() << '\n';
for(auto p : edges)
cout << p.first << ' ' << p.second << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |