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
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include<bits/stdc++.h>
#include "cielib.h"
#define fst(i) (limits[i].first)
#define snd(i) (limits[i].second)
#define dist(i) (limits[i].second - limits[i].first + 1)
#define pdk(i) (fst(i) + snd(i))/2
using namespace std;

const int MAXD = 501;

int d,k,r;
int cfound;
pair<int,int> limits[MAXD];
int position[MAXD];


void solve3() {
	for(int i = 0; i < d; i++) {
		position[i] = pdk(i);
	}
	for(int i = 0; i < d; i++) {
		position[i] = fst(i);
		czyCieplo(position);

		position[i] = snd(i);
		int right = czyCieplo(position);
		if(right) {
			fst(i) = snd(i) = position[i] = snd(i);
		}

		position[i] = fst(i);
		int left = czyCieplo(position);
		if(left) {
			fst(i) = snd(i) = position[i] = fst(i);
		}
		else {
			fst(i) = snd(i) = position[i] = pdk(i);
		}
	}
}


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

	for(int i = 0; i < d; i++) {
		fst(i) = 0;
		snd(i) = r;
		position[i] = r/2;
	}
	while(1) {
		bool flag = false;

		int mdist = 0;
		for(int i = 0; i < d; i++) {
			if(dist(i) > 3) flag = true;
			mdist = max(dist(i), mdist);
		}
		
//		cout << mdist << endl;

		if(!flag) {
			solve3();
			break;
		}

		for(int i = 0; i < d; i++) {
			if(dist(i) == 3 || dist(i) == 1)continue;
			
			position[i] = fst(i);
			czyCieplo(position);

			position[i] = snd(i);
			int right = czyCieplo(position);
			if(right) {
//				if(mdist == 4) cout << "BL " << fst(i) << ' ' << snd(i) << endl;
				fst(i) = pdk(i);
				if(dist(i)%2 == 0)fst(i)--;
//				if(mdist == 4) cout << "L " << fst(i) << ' ' << snd(i) << endl;
				position[i] = pdk(i);
				continue;
			}

			position[i] = fst(i);
			int left = czyCieplo(position);
			if(left) {
//				if(mdist == 4) cout << "Bef " << fst(i) << ' ' << snd(i) << endl;
				snd(i) = pdk(i)+1;
				if(dist(i)%2 == 0)fst(i)--;
//				if(mdist == 4) cout << "Right " << fst(i) << ' ' << snd(i) << endl;
				position[i] = pdk(i);
				continue;
			}
			else {
				if(dist(i)%2 == 0) {
//					if(mdist == 4) cout << "BM " << fst(i) << ' ' << snd(i) << endl;
					fst(i) = pdk(i);
					snd(i) = fst(i) + 2;
//					if(mdist == 4) cout << "M " << fst(i) << ' ' << snd(i) << endl;
					position[i] == fst(i)+1;
				}
				else {
					fst(i) = snd(i) = position[i] = pdk(i);
				}
			}
		}
		if(mdist == 4) break;
	}
	znalazlem(position);
}