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
#include <iostream>
#include <string>
#include <cctype>
#include <random>

typedef unsigned int uint;

#include "cielib.h"

int main()
{
	std::mt19937 rng;
	rng.seed(0x11223344);
	std::uniform_int_distribution<std::mt19937::result_type> next_rand(0, 1);

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

	int *a = new int[d];
	int *b = new int[d];

	for(int i = 0; i < d; ++i)
	{
		a[i] = 0;
		b[i] = r;
	}

	int *t = new int[d];

	while (true)
	{
		for (int curr = 0; curr < d; ++curr)
		{
			// std::cout << curr << ": " << a[curr] << " " << b[curr] << "\n";

			for (int i = 0; i < d; ++i)
			{
				if (i == curr)
				{
					t[i] = a[i];
				}
				else
				{
					t[i] = (a[i] + b[i] + next_rand(rng)) / 2;
				}
			}

			czyCieplo(t);

			while (true)
			{
				t[curr] = b[curr];

				if (czyCieplo(t))
				{
					a[curr] = (a[curr] + b[curr] + 1) / 2;
				}
				else
				{
					// break;
				}

				t[curr] = a[curr];

				if (czyCieplo(t))
				{
					b[curr] = (a[curr] + b[curr]) / 2;
				}
				else
				{
					break;
				}
			}

			if (a[curr] < b[curr])
			{
				t[curr] = a[curr] + 1;

				if (czyCieplo(t))
				{
					a[curr] = t[curr];
				}
			}

			if (a[curr] == b[curr])
			{
				znalazlem(t);

				break;
			}
		}
	}

	return 0;
}