이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
using namespace std;
constexpr static int MXLOG = 63;
int32_t main()
{
int k;
cin >> k;
vector<int> v;
vector<array<int, 2>> e;
int nxt = 1;
for (int i = 1; i <= 4; i++)
e.pb({0, nxt++});
v.pb(nxt-1);
for (int i = 1; i < MXLOG; i++)
{
for (int j = 0; j < 4; j++)
for (int l = 2; l <= 4; l++)
e.pb({nxt-l, nxt+j});
nxt+=3;
v.pb(nxt++);
}
for (int i = 0; i < 2; i++)
{
e.pb({nxt-1, nxt});
nxt++;
}
while (k != 0)
{
cout << k << "\n";
int i = 63 - __builtin_clzll(abs(k));
int s = -1;
if (i&1)
s = 1;
if (s == (abs(k) / k))
{
k -= (1<<i) * s;
e.pb({v[i], nxt-1});
}
else
{
k += (1<<(i+1)) * s;
e.pb({v[i+1], nxt-1});
}
}
nxt++;
cout << nxt << " " << e.size() << "\n";
for (auto [a, b] : e)
cout << (a+1) << " " << (b+1) << "\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... |