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
#include <algorithm>
#include <vector>
using namespace std;

#include "cielib.h"

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

  vector<int> base(d, 0);

  while (r > 1) {
    auto new_base = base;
    for (int i = 0; i < d; ++i) {
      auto p = base;
      for (int j = 0; j < d; ++j) p[j] += r / 2;
      p[i] = base[i];
      auto q = p;
      q[i] = base[i] + r;
      czyCieplo(p.data());
      if (czyCieplo(q.data())) {
        new_base[i] += r / 2;
      }
    }
    r = (r + 1) / 2;
    base = move(new_base);
  }

  if (r == 1) {
    auto new_base = base;
    for (int i = 0; i < d; ++i) {
      if (base[i] > 0) {
        auto p = base;
        p[i] -= 1;
        auto q = base;
        q[i] += 1;
        czyCieplo(p.data());
        if (czyCieplo(q.data())) ++new_base[i];
      } else {
        auto p = base;
        p[i] += 2;
        auto q = base;
        czyCieplo(p.data());
        if (!czyCieplo(q.data())) ++new_base[i];
      }
    }
    base = move(new_base);
    r = 0;
  }

  znalazlem(base.data());

  return 0;
}