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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "cielib.h"
#include <bits/stdc++.h>

using namespace std;

int d, k, r, x;
pair<int, int> t[1000];

int main()
{
    d = podajD();
    k = podajK();
    r = podajR();
    int p[d];
    int rz = r;
    for(int i = 0; i < d; i++)
    {
        t[i].first = 0;
        t[i].second = r;
    }
    for(int i = 0; i < d; i++) p[i] = (t[i].first + t[i].second) / 2;
    x = czyCieplo(p);
    while(t[d - 1].second - t[d - 1].first >= 3)
    {
        for(int i = 0; i < d; i++) p[i] = (t[i].first + t[i].second) / 2;
        x = czyCieplo(p);
        for(int i = 0; i < d; i++)
        {
            int s = (t[i].first + t[i].second) / 2;
            p[i] = t[i].second;
            int y = czyCieplo(p);
            p[i] = t[i].first;
            int z = czyCieplo(p);
            if(t[i].first - t[i].second % 2 == 0)
            {
                if(z == 1)
                    t[i].second = s, p[i] = t[i].first;
                else t[i].first = s, p[i] = t[i].second;
            }
            else
            {
                if(z == 1)
                    t[i].second = s + 1, p[i] = t[i].first;
                else t[i].first = s - 1, p[i] = t[i].second;
            }
            /*for(int i = 0; i < d; i++)
            {
                printf("%d %d   ", t[i].first, t[i].second);
            }*/
        }
    }
    //rz = min(rz, t[d - 1].second - t[d - 1].first - 1);
    //printf("%d         xxx      ", rz);
    if(r < 3) rz = r;
    else rz = t[d - 1].second - t[d - 1].first - 1;
    for(int i = 0; i < d; i++)
    {
        if(rz == 0) p[i] = 0;
        if(rz == 2)
        {
            p[i] = t[i].second;
            int g = czyCieplo(p);
            p[i] = t[i].first;
            int v = czyCieplo(p);
            if(v == 1) p[i] = t[i].first;
            else
            {
                p[i] = t[i].second;
                g = czyCieplo(p);
                if(g == 1) p[i] = t[i].second;
                else p[i] = t[i].first + 1;
            }
            if(rz == 1)
            {
                if(v == 1) p[i] = t[i].first;
                else p[i] = t[i].second;
            }
        }
    }
    znalazlem(p);
    return 0;
}