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
#include <cstdio>
#include <vector>
#include <algorithm>

#include "message.h"
#include "krazki.h"

long long data[200000001];
std::vector<std::pair<long long, int> > locks;

int discs = NumberOfDiscs();
int height = PipeHeight();

int last_pos = PipeHeight() + 1;
long long last_lock = -1;

int main() {
    if (MyNodeId() != 1) return EXIT_SUCCESS;

    long long diam = HoleDiameter(1);
    last_lock = diam;
    locks.push_back({diam, 1});
    data[1] = diam;
    
    for (int i = 2; i <= height; i++) {
        diam = HoleDiameter(i);
        if (diam < last_lock) {
            last_lock = diam;
            locks.push_back({diam, i});
        }
        data[i] = diam;
    }

    std::reverse(locks.begin(), locks.end());

    

    printf("%d", last_pos);

    return EXIT_SUCCESS;
}