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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <bits/stdc++.h>
#include "cielib.h"

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

/*************************************************************************/

bool askQuery(VI &vec) {
    const int MAXDIM = 502;
    
    int tab[MAXDIM];
    FORE(i,vec) tab[i] = vec[i];
    
    return czyCieplo(tab);
}

bool isCloser(VI &a, VI &b) {
    askQuery(a);
    return askQuery(b);
}

void answer(VI &pos) {
    const int MAXDIM = 502;
    
    int tab[MAXDIM];
    FORE(i,pos) tab[i] = pos[i];
    
    znalazlem(tab);
}

/*************************************************************************/

void findFixed(int l, int r, int dim, int n, VI &dims, VB &fixed, VI &pos) {
    VI shifted = pos;
    
    FOR(i,l,r) shifted[dims[i]]--;
    FOR(i,0,dim-1) shifted[i] = min(shifted[i] + 1, n);
    
    if (isCloser(pos, shifted)) {
        return ;
    } else if (l == r) {
        fixed[dims[l]] = true;
        return ;
    }
    
    int mid = (l + r) / 2;
    
    findFixed(l, mid, dim, n, dims, fixed, pos);
    findFixed(mid + 1, r, dim, n, dims, fixed, pos);
}

/*************************************************************************/

int main() {
    const int dim = podajD();
    const int n = podajR();
    
    VI pos(dim,0);
    VB fixedDim(dim,false);
    
    while (true) {
        VI dims;
        FOR(i,0,dim-1) if (!fixedDim[i]) {
            dims.pb(i);
        }

        findFixed(0, SIZE(dims)-1, dim, n, dims, fixedDim, pos);
        
        int l = -1, r = n - *max_element(pos.begin(), pos.end());
        while (r - l > 1) {
            int mid = (l + r) / 2;
            
            VI a = pos, b = pos;
            
            FOR(i,0,dim-1) if (fixedDim[i]) {
                a[i] += mid;
                b[i] += mid + 1;
            }
            
            if (isCloser(a, b)) {
                l = mid;
            } else {
                r = mid;
            }
        }
        
        FOR(i,0,dim-1) if (fixedDim[i]) {
            pos[i] += r;
        }
        
        if (find(fixedDim.begin(), fixedDim.end(), false) == fixedDim.end()) {
            break;
        }
    }
    
    bool found = true;
    FOR(i,0,dim-1) for (int diff = -1; diff <= 1; diff += 2) {
        VI q = pos;
        q[i] += diff;
        
        if (q[i] >= 0 && q[i] <= n) {
            if (!isCloser(q, pos)) {
                found = false;
            }
        }            
    }
    
    if (!found) {
        FOR(i,0,dim-1) {
            VI q = pos;
        
            if (pos[i] + 2 <= n) {
                q[i] += 2;
            
                if (!isCloser(q, pos)) {
                    pos[i]++;
                }
            } else {
                q[i]--;
            
                if (isCloser(q, pos)) {
                    pos[i]++;
                }
            }
        }
    }
    
    answer(pos);

    return 0;
}

/*************************************************************************/