이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 3e5 + 5;
int N = 1;
vector<pair<int,int>> edges;
vector<int> nodes_now;
void addEdge(int cnt, bool root) {
vector<int> new_nodes;
if (root) {
edges.push_back({1, N+1});
new_nodes.push_back(N+1);
N++;
}
for (int i = N+1; i <= N+cnt; i++)
new_nodes.push_back(i);
N += cnt;
for (auto u : nodes_now) {
for (auto to : new_nodes)
edges.push_back({u, to});
}
nodes_now = new_nodes;
}
void minus2() {
addEdge(2, false);
}
void minus1() {
addEdge(1, false);
}
void minusSm1() {
addEdge(1, true);
}
int main() {
fast
ll K;
cin >> K;
ll now = 0;
nodes_now.push_back(1);
for (int i = 63; i >= 0; i--) {
if ((1<<i) & K) {
minusSm1();
now = - 1 - now;
}
if (i != 0) {
minus2();
now *= -2;
}
if (now > 0) {
minus1();
now = -now;
}
}
if ((now < 0 && K > 0) || (now > 0 && K < 0))
minus1();
cout << N << " " << edges.size() << "\n";
for (auto u : edges)
cout << u.f << " " << u.s << "\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... |