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
#include "cielib.h"

#include <cstdlib>
#include <vector>

using namespace std;

int getRadius(int iter, long long k, int r) {
    long long border1 = k / 3;
    long long border2 = (2 * k) / 3;
    if (iter <= border1)
        return r;
    if (iter < border2) {
        long long x = iter - border1;
        long long maxx = border2 - border1;
        return (int) (r - (x * (r - 1)) / maxx);
    }
    return 1;
}

int main() {

    srand(2016);

	int d = podajD();
	int r = podajR();
    int k = podajK();

    vector<int> best(d, r / 2);
    vector<int> current(d, -1);

    for (int iter = 0; iter < k; ++iter) {
        if (current == best) {
            int radius = getRadius(iter, k, r);
            for (int i = 0; i < d; ++i) {
                int begin = max(0, current[i] - radius);
                int end = min(r, current[i] + radius);
                current[i] = begin + rand() % (end - begin + 1);
            }
            if (czyCieplo(current.data()) == 1) {
                best = current;
            }
        } else {
            czyCieplo(best.data());
            current = best;
        }
    }

	znalazlem(best.data());
    return 0;
}