#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
using namespace std;
constexpr static int MXLOG = 62;
int32_t main()
{
int k;
cin >> k;
int ccc = (k < 0) ? 1 : 0;
vector<int> v;
vector<array<int, 2>> e;
int nxt = 1;
for (int i = 1; i <= 3; i++)
e.pb({0, nxt++});
array<int, 3> last = {1, 2, 3};
if (ccc == 0)
{
e.pb({0, nxt});
v.pb(nxt++);
}
for (int i = 1; i < MXLOG; i++)
{
if (ccc == (i&1))
{
vector<int> vv;
for (int j = 0; j < 2; j++)
e.pb({last[j], nxt});
v.pb(nxt++);
for (int j = 0; j < 3; j++)
e.pb({last[j], nxt});
v.pb(nxt++);
}
for (int j = 0; j < 3; j++)
for (int l = 0; l < 3; l++)
e.pb({last[l], nxt+j});
for (int j = 0; j < 3; j++)
last[j] = nxt++;
}
for (int i = 0; i < 3; i++)
{
e.pb({nxt-1, nxt});
nxt++;
}
k = abs(k);
for (int i = 0; i < MXLOG; i++)
if (k&(static_cast<int>(1)<<i))
e.pb({v[i], nxt-1});
cout << nxt << " " << e.size() << "\n";
for (auto [a, b] : e)
cout << (a+1) << " " << (b+1) << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
348 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
0 ms |
348 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
344 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
0 ms |
348 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
348 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
0 ms |
348 KB |
Correct. |
6 |
Correct |
1 ms |
348 KB |
Correct. |
7 |
Correct |
1 ms |
348 KB |
Correct. |
8 |
Correct |
1 ms |
344 KB |
Correct. |
9 |
Correct |
0 ms |
348 KB |
Correct. |
10 |
Correct |
0 ms |
348 KB |
Correct. |
11 |
Correct |
1 ms |
348 KB |
Correct. |
12 |
Correct |
0 ms |
348 KB |
Correct. |
13 |
Correct |
1 ms |
344 KB |
Correct. |
14 |
Correct |
0 ms |
348 KB |
Correct. |
15 |
Correct |
0 ms |
348 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
348 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
0 ms |
348 KB |
Correct. |
6 |
Correct |
1 ms |
348 KB |
Correct. |
7 |
Correct |
1 ms |
348 KB |
Correct. |
8 |
Correct |
1 ms |
344 KB |
Correct. |
9 |
Correct |
0 ms |
348 KB |
Correct. |
10 |
Correct |
0 ms |
348 KB |
Correct. |
11 |
Correct |
1 ms |
348 KB |
Correct. |
12 |
Correct |
0 ms |
348 KB |
Correct. |
13 |
Correct |
1 ms |
344 KB |
Correct. |
14 |
Correct |
0 ms |
348 KB |
Correct. |
15 |
Correct |
0 ms |
348 KB |
Correct. |
16 |
Correct |
1 ms |
344 KB |
Correct. |
17 |
Correct |
0 ms |
344 KB |
Correct. |
18 |
Correct |
0 ms |
348 KB |
Correct. |
19 |
Correct |
1 ms |
348 KB |
Correct. |
20 |
Correct |
1 ms |
348 KB |
Correct. |
21 |
Correct |
0 ms |
344 KB |
Correct. |
22 |
Correct |
1 ms |
348 KB |
Correct. |
23 |
Correct |
1 ms |
348 KB |
Correct. |
24 |
Correct |
1 ms |
348 KB |
Correct. |
25 |
Correct |
1 ms |
348 KB |
Correct. |
26 |
Correct |
1 ms |
348 KB |
Correct. |
27 |
Correct |
1 ms |
348 KB |
Correct. |