#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n = 2;
vector<pair<int,int>> ans;
void build(vector<int> par, ll k, bool neg) {
if (k == 1) {
if (neg) {
vector<int> newpar = {n + 1, n + 2};
n += 2;
for (auto &i : par) {
for (auto &j : newpar) {
ans.emplace_back(i, j);
}
}
build(newpar, 1, neg ^ 1);
return;
}
for (auto &i : par) {
ans.emplace_back(i, 2);
}
return;
}
vector<int> newpar = {n + 1, n + 2, n + 3};
n += 3;
for (auto &i : par) {
for (auto &j : newpar) {
ans.emplace_back(i, j);
}
}
build(newpar, k >> 1, neg ^ 1);
if (k & 1) {
if (par.size() == 1) {
ans.emplace_back(1, n);
ans.emplace_back(n, 2);
n++;
} else {
vector<int> newpar = {n + 1, n + 2};
n += 2;
for (auto &i : par) {
for (auto &j : newpar) {
ans.emplace_back(i, j);
}
}
build(newpar, 1, neg ^ 1);
}
}
}
void solve() {
ll k;
cin >> k;
if (k == 0) {
cout << "3 2\n1 2\n2 3\n";
return;
}
bool neg = k > 0;
build({1}, abs(k), neg);
cout << n << " " << (int) ans.size() << '\n';
for (int i = 0; i < (int) ans.size(); i++) {
if (ans[i].first == 2 || ans[i].first == n) ans[i].first = n + 2 - ans[i].first;
if (ans[i].second == 2 || ans[i].second == n) ans[i].second = n + 2 - ans[i].second;
cout << ans[i].first << " " << ans[i].second << '\n';
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int tc = 1;
//cin >> tc;
while (tc--) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Wrong output format. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Wrong output format. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Wrong output format. |
2 |
Halted |
0 ms |
0 KB |
- |