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
#include <bits/stdc++.h>
#include "cielib.h"

int dim, p[501], l[501], dl;
int wynik[501];
void binserczuj_z_tym() {
	int tab[501];
	for (int i = 0; i <= dim; i++) {
		p[i] = dl;
		l[i] = 0;
		tab[i] = (p[i]+l[i])/2;
	}
	int maks = dl;
	while (maks > 1) {
		maks = p[0] - l[0];
		for (int i = 0; i < dim; i++) {
			int temp = tab[i];
			tab[i] = p[i];
			int pt = czyCieplo(tab);
			tab[i] = l[i];
			pt = czyCieplo(tab);
			if (pt == 1) 
				p[i] = (p[i] + l[i] + 1)/2;
			else
				l[i] = temp;
			tab[i] = (p[i] + l[i])/2;
			maks = (maks > p[i] - l[i]) ? maks : p[i] - l[i];
		}
	}
	
	for (int i = 0; i < dim; i++) {
		int pt;
		int temp = tab[i];
		if (temp == 0) {
			tab[i] = 2;
			pt = czyCieplo(tab);
			tab[i] = 0;
			pt = czyCieplo(tab);
			tab[i] = 1 - pt;
		} else {
			tab[i]--;
			pt = czyCieplo(tab);
			tab[i] += 2;
			pt = czyCieplo(tab);
			tab[i] += (pt-1);
		}
	}
	znalazlem(tab);
	return; 
}

int main() {
	dim = podajD();
	dl = podajR();
	binserczuj_z_tym();
	return 0;
}