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
#include <iostream>
#include <queue>
#include <utility>
#include "cielib.h"
using namespace std;
class CompareDist {
public:
    bool operator()(pair<int,int> n1,pair<int,int> n2) {
        return n1.second<n2.second;
    }
};
int main() {
    int d, k, r, t;
    d = podajD();
    k = podajK();
    r = podajR();
    int *st, *nd, *ask;
    st = new int[d+2];
    nd = new int[d+2];
    ask = new int[d+2];
    int answer;
    priority_queue<pair<int,int>,vector<pair<int,int> >,CompareDist> que;
    for(int i=0; i<d; i++) {
        st[i] = 0;
        nd[i] = r;
        que.push(make_pair(i, r));
    }
    while(que.top().second && k > 1) {
        k -= 2;
        t = que.top().first;
        que.pop();
        for(int i=0; i<d; i++)
            if(i != t)
                ask[i] = (st[i] + nd[i]) / 2;
            else
                ask[i] = st[i];
        answer = czyCieplo(ask);
        ask[t] = nd[t];
        answer = czyCieplo(ask);
        if(answer)
            st[t] = (st[t] + nd[t]) / 2 + 1;
        else
            nd[t] = (st[t] + nd[t]) / 2;
        que.push(make_pair(t, nd[t]-st[t]));
    }
    znalazlem(st);
    return 0;
}