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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <cstdio>
#include <vector>

#include "cielib.h"

using p = std::pair <int, int>;
using vector = std::vector <p>;

int coo [500];
bool found [500];

void binsearch (vector V, int r)
{
    bool flag = 1;
    for (int i = 0; i < V.size (); ++ i)
    {
        coo [i] = (V [i].first + V [i].second) / 2;
        if (V [i].first == V [i].second)
            found [i] = 1;
        else
        {
            flag = 0;
            found [i] = 0;
        }
    }
    if (flag)
    {
        znalazlem (coo);
        return;
    }
    for (int i = 0; i < V.size (); ++ i)
    {
        if (found [i])
            continue;
        int act = czyCieplo(coo);
        int diff;
        if (coo [i] + 1 < r)
        {
            ++ coo [i];
            diff = 1;
        }
        else
        {
            -- coo [i];
            diff = -1;
        }
        int nxt = czyCieplo(coo);
        if (nxt == 1)
        {
            if (diff == 1)
            {
                V [i] = p(coo [i], V [i].second);
            }
            else
            {
                V [i] = p(V [i].first, coo [i]);
            }
            binsearch (V, r);
            break;
        }
        coo [i] -= 2 * diff;
        if (coo [i] < 0)
        {
            coo [i] += 2 * diff;
            continue;
        }
        nxt = czyCieplo(coo);
        if (nxt == 1)
        {
            if (diff == -1)
            {
                V [i] = p(coo [i], V [i].second);
            }
            else
            {
                V [i] = p(V [i].first, coo [i]);
            }
            binsearch (V, r);
            break;
        }
        coo [i] += 2 * diff;
        nxt = czyCieplo(coo);
        if (nxt == 1)
        {
            if (diff == 1)
            {
                V [i] = p(coo [i], V [i].second);
            }
            else
            {
                V [i] = p(V [i].first, coo [i]);
            }
            binsearch (V, r);
            break;
        }
        coo [i] -= diff;
    }
}

int main ()
{
    int d = podajD();
    int k = podajK();
    int r = podajR();
    vector v;
    for (int i = 0; i < d; ++ i)
    {
        v.push_back (p (0, r));
    }
    binsearch (v, r + 1);
    return 0;
}