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
#ifdef _MSC_VER
  #ifndef __GNUC__
    #pragma warning(disable: 4996)
  #endif
  #define main main0
#endif
#include "cielib.h"
#include <algorithm>
#include <memory>
using namespace std;

int d, k, r;
int t0[500];
int t1[500];

void GetNode() {
  int change = r;
  do {
    int node = 0;
    swap(t0[0], t1[0]);
    czyCieplo(t0);
    swap(t0[0], t1[0]);
    for(int i = 1; i < d; ++i) {
      swap(t0[i], t1[i]);
      if(czyCieplo(t0) == 1)
        node = i;
      swap(t0[i], t1[i]);
    }
    for(int i = 0; i < d; ++i) {
      if(i != node) {
        int tmp = t1[i];
        t1[i] = (t0[i] + t1[i]) / 2;
      }
      else {
        int tmp = t0[i];
        t0[i] = (t0[i] + t1[i]) / 2;
      }
    }
  } while((change /= 2) > 0);
}

int main() {
  d = podajD();
  k = podajK();
  r = podajR();
  for(int i = 0; i < d; ++i) {
    t0[i] = 0;
    t1[i] = r;
  }
  GetNode();
  znalazlem(t1);
  return 0;
}