#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int64_t k;
int64_t pow2 = 1;
cin >> k;
bool isneg = k < 0;
if (isneg) k = -k;
int* from = new int[1000];
int* to = new int[1000];
from[0] = 1;
to[0] = 2;
from[1] = 2;
to[1] = 3;
from[2] = 2;
to[2] = 4;
int edgecount = 3;
int vertexcount = 4;
while (pow2 * 2 <= k) pow2 *= 2;
while (pow2 > 0){
from[edgecount] = vertexcount - 1;
to[edgecount] = vertexcount + 1;
from[edgecount + 1] = vertexcount - 1;
to[edgecount + 1] = vertexcount + 2;
from[edgecount + 2] = vertexcount - 1;
to[edgecount + 2] = vertexcount + 3;
from[edgecount + 3] = vertexcount;
to[edgecount + 3] = vertexcount + 1;
from[edgecount + 4] = vertexcount;
to[edgecount + 4] = vertexcount + 2;
from[edgecount + 5] = vertexcount;
to[edgecount + 5] = vertexcount + 3;
from[edgecount + 6] = vertexcount + 1;
to[edgecount + 6] = vertexcount + 4;
from[edgecount + 7] = vertexcount + 2;
to[edgecount + 7] = vertexcount + 4;
from[edgecount + 8] = vertexcount + 3;
to[edgecount + 8] = vertexcount + 4;
from[edgecount + 9] = vertexcount + 1;
to[edgecount + 9] = vertexcount + 5;
from[edgecount + 10] = vertexcount + 2;
to[edgecount + 10] = vertexcount + 5;
from[edgecount + 11] = vertexcount + 3;
to[edgecount + 11] = vertexcount + 5;
vertexcount += 5;
edgecount += 12;
if ((k / pow2) % 2 == 1){
from[edgecount] = vertexcount - 1;
to[edgecount] = vertexcount + 1;
from[edgecount + 1] = vertexcount - 1;
to[edgecount + 1] = vertexcount + 2;
from[edgecount + 2] = vertexcount;
to[edgecount + 2] = vertexcount + 1;
from[edgecount + 3] = vertexcount;
to[edgecount + 3] = vertexcount + 2;
from[edgecount + 4] = 1;
to[edgecount + 4] = vertexcount + 3;
from[edgecount + 5] = vertexcount + 1;
to[edgecount + 5] = vertexcount + 4;
from[edgecount + 6] = vertexcount + 2;
to[edgecount + 6] = vertexcount + 4;
from[edgecount + 7] = vertexcount + 3;
to[edgecount + 7] = vertexcount + 4;
from[edgecount + 8] = vertexcount + 1;
to[edgecount + 8] = vertexcount + 5;
from[edgecount + 9] = vertexcount + 2;
to[edgecount + 9] = vertexcount + 5;
from[edgecount + 10] = vertexcount + 3;
to[edgecount + 10] = vertexcount + 5;
vertexcount += 5;
edgecount += 11;
}
pow2 /= 2;
}
if (isneg){
from[edgecount] = vertexcount - 1;
to[edgecount] = vertexcount + 1;
from[edgecount + 1] = vertexcount;
to[edgecount + 1] = vertexcount + 1;
edgecount += 2;
vertexcount += 1;
}
cout << vertexcount << " " << edgecount << endl;
for (int i = 0; i < edgecount; i++){
cout << from[i] << " " << to[i] << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct. |
2 |
Correct |
0 ms |
348 KB |
Correct. |
3 |
Correct |
0 ms |
348 KB |
Correct. |
4 |
Correct |
1 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
600 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
348 KB |
Correct. |
4 |
Correct |
1 ms |
348 KB |
Correct. |
5 |
Correct |
0 ms |
348 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct. |
2 |
Correct |
0 ms |
348 KB |
Correct. |
3 |
Correct |
0 ms |
348 KB |
Correct. |
4 |
Correct |
1 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
600 KB |
Correct. |
6 |
Correct |
1 ms |
344 KB |
Correct. |
7 |
Correct |
1 ms |
348 KB |
Correct. |
8 |
Correct |
1 ms |
348 KB |
Correct. |
9 |
Correct |
1 ms |
348 KB |
Correct. |
10 |
Correct |
0 ms |
348 KB |
Correct. |
11 |
Correct |
1 ms |
348 KB |
Correct. |
12 |
Correct |
1 ms |
348 KB |
Correct. |
13 |
Correct |
1 ms |
348 KB |
Correct. |
14 |
Correct |
1 ms |
348 KB |
Correct. |
15 |
Correct |
0 ms |
600 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct. |
2 |
Correct |
0 ms |
348 KB |
Correct. |
3 |
Correct |
0 ms |
348 KB |
Correct. |
4 |
Correct |
1 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
600 KB |
Correct. |
6 |
Correct |
1 ms |
344 KB |
Correct. |
7 |
Correct |
1 ms |
348 KB |
Correct. |
8 |
Correct |
1 ms |
348 KB |
Correct. |
9 |
Correct |
1 ms |
348 KB |
Correct. |
10 |
Correct |
0 ms |
348 KB |
Correct. |
11 |
Correct |
1 ms |
348 KB |
Correct. |
12 |
Correct |
1 ms |
348 KB |
Correct. |
13 |
Correct |
1 ms |
348 KB |
Correct. |
14 |
Correct |
1 ms |
348 KB |
Correct. |
15 |
Correct |
0 ms |
600 KB |
Correct. |
16 |
Correct |
1 ms |
348 KB |
Correct. |
17 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
18 |
Halted |
0 ms |
0 KB |
- |