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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include "cielib.h"

using namespace std;

const int MAXD = 505;

int d, r;
int ret[MAXD];
int poc[MAXD];
int kon[MAXD];

int main() {
    d = podajD();
    r = podajR();
    for(int i = 0 ; i < d; i++) {
        kon[i] = r;
        ret[i] = r/2;
    }
    int diff = r;
    while(diff > 1) {
        diff = 0;

        for(int i = 0; i < d; i++) {
            ret[i] = poc[i];
            czyCieplo(ret);
            ret[i] = kon[i];
            if(czyCieplo(ret)) {
                poc[i] = (poc[i] + kon[i]) / 2;
            }
            else {
                kon[i] = (poc[i] + kon[i] + 1) / 2;
            }
            ret[i] = (kon[i] + poc[i] + 1) / 2;
            diff = max(diff, kon[i] - poc[i]);
        }

    }
    for(int i = 0; i < d; i++) {
        if(poc[i] == 0) {
            ret[i] = kon[i] + 1;
            czyCieplo(ret);
            ret[i] = poc[i];
            if(!czyCieplo(ret)) {
                ret[i] = kon[i];
            }
        }
        else {
            ret[i] = poc[i] - 1;
            czyCieplo(ret);
            ret[i] = kon[i];
            if(!czyCieplo(ret)) {
                ret[i] = poc[i];
            }
        }
    }
    znalazlem(ret);
    return 0;
}