#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll k;
int n = 2;
vector<pair<int,int>> ans;
void build(bool dep, ll num, vector<int> par) {
if (num == 1) {
if (!dep) {
vector<int> newpar = {n + 1, n + 2};
n += 2;
for (auto &i : par) {
for (auto &j : newpar) {
ans.push_back({i, j});
}
}
build(true, 1, newpar);
return;
}
for (auto i : par) {
ans.push_back({i, 2});
}
} else {
vector<int> newpar = {n + 1, n + 2, n + 3};
n += 3;
for (auto i : par) {
for (auto j : newpar) {
ans.push_back({i, j});
}
}
build(dep ^ 1, num / 2, newpar);
if (k & 1) {
newpar = {n + 1};
n++;
for (auto i : par) {
ans.push_back({i, n});
}
build(dep ^ 1, 1, newpar);
}
}
}
void solve() {
cin >> k;
if (k == 0) {
cout << "3 2\n1 2\n2 3\n";
return;
}
bool dep = false;
if (k < 0) dep ^= 1;
k = abs(k);
build(dep, k, {1});
for (auto &[i,j] : ans) {
if (i == 2 || i == n) i = n + 2 - i;
if (j == 2 || j == n) j = n + 2 - j;
cout << i << " " << j << '\n';
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int tc = 1;
//cin >> tc;
while (tc--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer parameter [name=Y_1] equals to 4, violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer parameter [name=Y_1] equals to 4, violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer parameter [name=Y_1] equals to 4, violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer parameter [name=Y_1] equals to 4, violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |