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

int D,K,R;

std::vector<int> search(const std::vector<std::pair<int,int> > &cube) {
	int query[D];
	bool ok = true;
	std::vector<std::pair<int,int> > ncube;
	std::vector<int> res;

	for (int i=0; i<D; ++i) {
		if (cube[i].second-cube[i].first>=2) ok = false;
		query[i] = (cube[i].first + cube[i].second)/2;
	}

	if (ok) {
		//check left
		for (int i=0; i<D; ++i) {
			if (cube[i].second == R) {
				query[i]=cube[i].first-1;
				czyCieplo(query);
				query[i]=cube[i].second;
				if (czyCieplo(query)) {
					res.push_back(cube[i].second);
				} else {
					res.push_back(cube[i].first);
				}
			} else {
				query[i]=cube[i].second + 1;
				czyCieplo(query);
				query[i]=cube[i].first;
				if (czyCieplo(query)) {
					res.push_back(cube[i].first);
				} else {
					res.push_back(cube[i].second);
				}
			}

		}

		return res;
	}

	for (int i=0; i<D; ++i) {
		query[i]=cube[i].first;
		czyCieplo(query);
		query[i]=cube[i].second;
		if (czyCieplo(query)) {
			ncube.push_back(std::pair<int,int>((cube[i].first + cube[i].second)/2 , cube[i].second));
		} else {
			ncube.push_back(std::pair<int,int>(cube[i].first, (cube[i].first + cube[i].second + 1)/2));
		}

		query[i] = (cube[i].first + cube[i].second)/2;
	}

	return search(ncube);
}

int main() {
	D = podajD();
	K = podajK();
	R = podajR();

	std::vector<std::pair<int, int> > query;
	std::vector<int> result;
	int ares[D];

	for (int i=0; i<D; i++) {
		query.push_back(std::pair<int,int>(0,R));
	}

	result = search(query);
	for (int i=0; i<D; ++i) {
		ares[i] = result[i];
	}
	
	znalazlem(ares);
	return 0;
}