1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Karol Kosinski 2020
#include <cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

struct Vertex { int x, y; };

bool Bits[33];
Vertex V[99];

int main()
{
    int k, b = 0;
    scanf("%d", &k);
    while (k > 0)
    {
        Bits[ b ++ ] = (k % 2 == 1);
        k /= 2;
    }
    int n = 3 * (b - 1) + 2;
    V[1].x = 2;
    V[1].y = -1;
    FOR(i,1,b)
    {
        V[ 3 * i - 1 ].x    = 3 * i;
        V[ 3 * i - 1 ].y    = 3 * i + 1;
        V[ 3 * i ].x        = 3 * i + 2;
        V[ 3 * i ].y        = -1;
        V[ 3 * i + 1 ].x    = 3 * i + 2;
        V[ 3 * i + 1 ].y    = -1;
    }
    if (b - 2 >= 0 and Bits[ b - 2 ])
    {
        FOR(i,1,b) V[ 3 * i - 2 ].y = n;
    }
    FOR(i,0,b-2)
    {
        if (Bits[i]) V[ 3 * i + 3 ].y = n;
    }
    printf("%d\n", n);
    FOR(i,1,n) printf("%d %d\n", V[i].x, V[i].y);
    printf("-1 -1\n");
    return 0;
}