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
91
92
93
#include<bits/stdc++.h>
#define PII pair<int,int>
#define f first
#define s second
#define VI vector<int>
#define LL long long
#define MP make_pair
#define LD long double
#define PB push_back
#define ALL(V) V.begin(),V.end()
#define abs(x) max((x),-(x))
#define PDD pair<LD,LD> 
#define VPII vector< PII > 
#define siz(V) ((int)V.size())
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
#define FORD(x, b, e) for(int x=b;x>=(e);x--)
#define REP(x, n)     for(int x=0;x<(n);x++)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#ifdef DEB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
#include "cielib.h"
using namespace std;
const int MD = 5e2 + 4;
int low[MD], high[MD];
int query1[MD], query2[MD];
int main() {
	int d = podajD();
	int r = podajR();
	podajK();
	for (int i = 0; i < d; ++i) high[i] = r;
	while (true) {
		for (int i = 0; i < d; ++i) {
			debug("[%d, %d]%c", low[i], high[i], i == d - 1 ? '\n' : 'x');
		}
		int wh = -1, mdist = 1;
		for (int i = 0; i < d; ++i) {
			if (mdist <= high[i] - low[i]) {
				mdist = high[i] - low[i];
				wh = i;
			}
		}
		if (wh == -1) break;
		debug("try %d\n", wh);
		for (int i = 0; i < d; ++i) 
			query1[i] = query2[i] = (low[i] + high[i]) / 2;
		
		if ((high[wh] - low[wh]) % 2) {
			if (low[wh] > 0) {
				query1[wh] = low[wh] - 1;
				query2[wh] = high[wh];
				czyCieplo(query1);
				if (czyCieplo(query2))
					low[wh] = (low[wh] + high[wh]) / 2 + 1;
				else
					high[wh] = (low[wh] + high[wh]) / 2;
			}
			else if (high[wh] < r) {
				debug("case 2\n");
				query1[wh] = high[wh] + 1;
				query2[wh] = low[wh];
				czyCieplo(query1);
				if (czyCieplo(query2))
					high[wh] = (low[wh] + high[wh]) / 2;
				else
					low[wh] = (low[wh] + high[wh]) / 2 + 1;
			}
			else {
				debug("case 3\n");
				query1[wh] = 0;
				query2[wh] = r;
				czyCieplo(query1);
				if (czyCieplo(query2))
					low[wh] = (low[wh] + high[wh] + 1) / 2;
				else
					high[wh] = (low[wh] + high[wh] + 1) / 2;
			}
		}
		else {
			query1[wh] = low[wh];
			query2[wh] = high[wh];
			czyCieplo(query1);
			if (czyCieplo(query2))
				low[wh] = (low[wh] + high[wh]) / 2 + 1;
			else
				high[wh] = (low[wh] + high[wh]) / 2;
		}
	}
	znalazlem(low);
}