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
#include "cielib.h"
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=510;
int l[N],r[N],dia,d,k,R,md[N],p[N],ret[N],cl[N],cr[N];
int main() {
	d=podajD(); k=podajK(); R=podajR();
	rep(i,0,d) l[i]=0,r[i]=R; dia=R;
	while (dia>2) {
		rep(i,0,d) md[i]=(l[i]+r[i])/2,p[i]=md[i];
		rep(i,0,d) {
			p[i]=l[i];
			czyCieplo(p);
			p[i]=r[i];
			int v1=czyCieplo(p);
			if (v1==0) {
				cl[i]=l[i]; cr[i]=(l[i]+r[i]+1)/2;
			} else {
				cl[i]=(l[i]+r[i])/2,cr[i]=r[i];
			}
			p[i]=md[i];
		}
		dia=0;
		rep(i,0,d) dia=max(dia,cr[i]-cl[i]),l[i]=cl[i],r[i]=cr[i];
		rep(i,0,d) {
			if (r[i]-l[i]<dia) l[i]=max(l[i]-dia,0);
			if (r[i]-l[i]<dia) r[i]=min(r[i]+dia,R);
		}
	}
	rep(i,0,d) md[i]=(l[i]+r[i])/2,p[i]=md[i];
	rep(i,0,d) {
		p[i]=l[i];
		czyCieplo(p);
		p[i]=md[i];
		int v1=czyCieplo(p);
		p[i]=r[i];
		czyCieplo(p);
		p[i]=md[i];
		int v2=czyCieplo(p);
		if (v1==v2) ret[i]=md[i];
		else if (v1) ret[i]=r[i];
		else ret[i]=l[i];
	}
	znalazlem(ret);
}