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 <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
long long k; cin >> k;
if (k == 0) {
cout << "3 2\n1 2\n2 3\n";
return 0;
}
bool neg = k < 0 ? k = -k, true : false;
vector<int> cur(1, 1), nxt;
vector<pair<int, int>> edges;
int n = 1;
for (int i = 62 - __builtin_clzll(k); i >= 0; i--) {
for (int j = 1; j <= 3; j++)
nxt.push_back(++n);
for (int u : cur)
for (int v : nxt)
edges.emplace_back(u, v);
if (k >> i & 1) {
nxt.push_back(++n);
edges.emplace_back(1, n);
}
swap(cur, nxt); nxt.clear();
for (int j = 1; j <= 2; j++)
nxt.push_back(++n);
for (int u : cur)
for (int v : nxt)
edges.emplace_back(u, v);
swap(cur, nxt); nxt.clear();
}
if (!neg) {
for (int j = 1; j <= 2; j++)
nxt.push_back(++n);
for (int u : cur)
for (int v : nxt)
edges.emplace_back(u, v);
swap(cur, nxt); nxt.clear();
}
++n;
for (int u : cur)
edges.emplace_back(u, n);
cout << n << ' ' << edges.size() << '\n';
for (auto e : edges)
cout << e.first << ' ' << e.second << '\n';
}
# | 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... |