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
// tell me a superman story and hope that dc code is cool about this
#include "cielib.h"

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
template<typename T> ostream& operator<<(ostream& s, vector<T> t) {rep(i, 0, t.size()) s << (i ? " " : "") << t[i]; return s;}
template<typename T> istream& operator>>(istream& s, vector<T> &t) {rep(i, 0, t.size()) s >> t[i]; return s;}
typedef long long ll;

int main() {
    int d = podajD();
    int r = podajR();
    vector<int> from(d, 0), to(d, r);
    int t[d];
    
    int maxRange = r;
    do {
        int range = maxRange;
        maxRange = 0;
        rep(i, 0, d) t[i] = (to[i] + from[i]) / 2;
        rep(i, 0, d) {
            if (from[i] + 1 >= to[i]) continue;
            t[i] = to[i];
            czyCieplo(t);
            t[i] = from[i];
            bool b0 = czyCieplo(t);
            t[i] = to[i];
            bool b1 = czyCieplo(t);
            t[i] = (to[i] + from[i]) / 2;
            
            assert(!b0 || !b1);
            if (b0) {
                to[i] = (from[i] + to[i] - 1) / 2;
            } else if (b1) {
                from[i] = (from[i] + to[i] + 2) / 2;
            } else {
                int f0 = from[i], t0 = to[i];
                from[i] = t0 - (range + 1) / 2;
                to[i] = f0 + (range + 1) / 2;
                assert(from[i] <= to[i]);
            }
            maxRange = max(maxRange, to[i] - from[i]);
        }
        
        /*rep(i, 0, d) {
            cout << i << ": " << from[i] << "-" << to[i] << endl;
        }
        cout << endl;*/
    } while (maxRange > 1);
    
    rep(i, 0, d) t[i] = (to[i] + from[i]) / 2;
    
    rep(i, 0, d) {
        if (from[i] != to[i]) {
            assert(from[i] + 1 == to[i]);
            if (from[i] > 0) {
                t[i] = from[i] - 1;
                czyCieplo(t);
                t[i] = to[i];
                if (czyCieplo(t)) {
                    from[i] = to[i];
                } else {
                    to[i] = from[i];
                }
            } else {
                assert(to[i] < d);
                t[i] = to[i] + 1;
                czyCieplo(t);
                t[i] = from[i];
                if (czyCieplo(t)) {
                    to[i] = from[i];
                } else {
                    from[i] = to[i];
                }
            }
        }
    }
    rep(i, 0, d) t[i] = (to[i] + from[i]) / 2;
    
    /*rep(i, 0, d) {
        cout << i << ": " << from[i] << "-" << to[i] << endl;
    }*/
    znalazlem(t);
}