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

#include <cstring>

bool isHot(int d_idx, int d_max, int r, int pos){
    if(pos == -1 || pos == r + 1){
        return false;
    }
    
    int v[d_max] ;
    memset( v, 0, d_max*sizeof(int) );
    
    v[d_idx] = pos;
    
    return czyCieplo(v);
}

int getSubPosition(int d_idx, int d_max,  int r){
    int b = 0;
    int e = r;
    
    while(b != e){
        int mid = (e-b)/2 + b;
        bool left, center, right;
        center = isHot(d_idx, d_max, r, mid);
        left = isHot(d_idx, d_max, r, mid-1);
        right = isHot(d_idx, d_max, r, mid+1);
        
        if(!left && !right){
            return mid;
        }
            
        if(left){
            if(mid-b == 1){
                return b;
            }
            
            e = mid;
        }
        else{
            if(e-mid == 1){
                return e;
            }
            
            b = mid;
        }
    }
    
    return b;
}

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

    int result[d];
    for(int i=0; i<d; ++i){
        result[i] = getSubPosition(i, d, r);
    }
    
    znalazlem(result);
}