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
83
84
85
86
87
88
89
90
#include <iostream>
#include <algorithm>
#include "cielib.h"

using namespace std;

const int MAX_D = 500;

int result[MAX_D], bound_l[MAX_D], bound_r[MAX_D], position[MAX_D];
bool found[MAX_D];

int how_many_found;

bool shorten_bounds(int p) {
	if (found[p]) return true;
	
	if ((bound_r[p] - bound_l[p]) % 2 == 1) {
		--bound_l[p];
		return shorten_bounds(p);
	}
	
	if (bound_l[p] == bound_r[p]) {
		found[p] = true;
		result[p] = bound_l[p];
		++how_many_found;
		
		return true;
	}
	
	int a, b, mid;
	mid = (bound_l[p] + bound_r[p]) / 2;
	
	position[p] = bound_l[p];
	a = czyCieplo(position);
	position[p] = bound_r[p];
	a = czyCieplo(position);
	
	if (a == 1) {
		bound_l[p] = mid + 1;
		position[p] = (bound_l[p] + bound_r[p]) / 2;
		return false;
	}
	
	position[p] = bound_l[p];
	b = czyCieplo(position);
	
	if (b == 1) {
		bound_r[p] = mid - 1;
		position[p] = (bound_l[p] + bound_r[p]) / 2;
		return false;
	} else {
		found[p] = true;
		result[p] = mid;
		position[p] = mid;
		++how_many_found;
		
		return true;
	}
}

int main() {
	int d = podajD(), k = podajK(), r = podajR();
	
	for (int i = 0; i < d; i++) {
		result[i] = -1;
		bound_l[i] = 0;
		bound_r[i] = r;
		
		position[i] = r / 2;
		
		found[i] = false;
	}
	
	how_many_found = 0;
	
	while (how_many_found != d) {
		for (int i = 0; i < d; i++) {
			if (!found[i]) {
				found[i] = shorten_bounds(i);
			}
		}
	}
	
	int res[d];
	for (int i = 0; i < d; i++) {
		res[i] = result[i];
	}
	
	znalazlem(res);
}