QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#676661#9432. Permutationucup-team5367#AC ✓274ms4100kbC++172.8kb2024-10-25 22:52:452024-10-25 22:52:46

Judging History

你现在查看的是最新测评结果

  • [2024-10-25 22:52:46]
  • 评测
  • 测评结果:AC
  • 用时:274ms
  • 内存:4100kb
  • [2024-10-25 22:52:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 10;
const int inf1 = 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxn = 1010;
int n, ds[maxn], dsz[maxn];

int find(int v) {
    if(v == ds[v]) return ds[v];
    return ds[v] = find(ds[v]);
}

void join(int u, int v) {
    u = find(u);
    v = find(v);
    if(u == v) return;
    if(dsz[u] < dsz[v]) swap(u,v);
    dsz[u]+= dsz[v];
    ds[v] = u;
}

int ask(vector<int> a) {
    cout << 0 << " ";
    for(auto x : a) cout << x << " ";
    cout << endl;
    cout.flush();
    int x;
    cin >> x;
    return x;
}
vector<int> sol(vector<int> a, int l, int r) {
    if(a.size() == 1) return a;
    vector<int> a0 = a;

    for(auto i : a) {
        ds[i] = i;
        dsz[i] = 1;
    }

    int mid = (l+r)/2;
    vector<int> qrr(n,a[0]);

    vector<int> islr(n+2,-1);
    int ql = 0;
    int qr = 0;
    while(ql != (mid-l+1) and qr != (r-(mid+1)+1)) {
        shuffle(all(a),rng);
        int x = a.back(); a.pop_back();
        int y = a.back(); a.pop_back();

        for(int i = l; i <= mid; i++) qrr[i] = x;
        for(int i = mid+1; i <= r; i++) qrr[i] = y;

        int ansq = ask(qrr);

        if(ansq == 2) {
            islr[x] = 0;
            ql+= dsz[x];

            islr[y] = 1;
            qr+= dsz[y];
        }
        else if(ansq == 0) {
            islr[x] = 1;
            qr+= dsz[x];

            islr[y] = 0;
            ql+= dsz[y];
        }
        else {
            join(x,y);
            a.pb(find(x));
        }
    }

    while(ql != (mid-l+1)) {
        int x = a.back(); a.pop_back();
        islr[x] = 0;
        ql+= dsz[x];
    }

    while(qr != (r-(mid+1)+1)) {
        int x = a.back(); a.pop_back();
        islr[x] = 1;
        qr+= dsz[x];
    }


    vector<int> al,ar;
    for(auto i : a0) {
        if(islr[find(i)] == 0) al.pb(i);
        else ar.pb(i);
    }

    al = sol(al,l,mid);
    ar = sol(ar,mid+1,r);
    a.clear();
    for(auto x : al) a.pb(x);
    for(auto x : ar) a.pb(x);
    return a;
}

void solve() {
    cin >> n;
    vector<int> a;
    for(int i = 1; i <= n; i++) {
        a.pb(i);
    }
    a = sol(a,0,n-1);

    cout << 1 << " ";
    for(auto x : a) cout << x << " ";
    cout << endl;
    cout.flush();

}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // #ifndef ONLINE_JUDGE
    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    // #endif

    int tt = 1;
    // cin >> tt;
    while(tt--) {
        solve();
    }

}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3624kb

input:

5
0
1
0
1
0
0
0

output:

0 1 1 1 2 2 
0 4 4 4 3 3 
0 5 5 5 4 4 
0 3 3 4 2 2 
0 2 2 3 2 2 
0 4 3 3 3 3 
0 1 1 1 5 1 
1 3 4 2 1 5 

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 252ms
memory: 3812kb

input:

1000
1
2
0
1
0
1
1
0
1
1
0
0
2
1
1
1
0
2
0
1
1
0
1
2
1
1
0
0
1
0
2
0
2
2
1
1
1
0
1
1
2
2
0
1
2
2
1
0
1
1
0
1
2
1
2
1
0
1
2
2
2
0
1
1
0
1
0
2
1
2
1
2
1
1
2
0
0
0
1
0
2
1
1
1
0
1
1
1
1
1
1
1
1
0
2
1
2
1
1
1
1
0
2
2
1
1
2
1
2
2
0
2
1
1
0
2
0
1
0
2
1
1
1
0
1
1
2
1
2
2
0
2
2
1
1
2
2
1
1
2
0
1
1
1
1
1
0
1...

output:

0 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 597 59...

result:

ok Accepted

Test #3:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

2
2

output:

0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

3
1
0
0

output:

0 1 1 3 
0 2 2 1 
0 1 3 1 
1 3 1 2 

result:

ok Accepted

Test #6:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

4
2
0
0
0

output:

0 3 3 1 1 
0 2 2 4 4 
0 4 3 3 3 
0 1 1 1 2 
1 3 4 2 1 

result:

ok Accepted

Test #7:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

6
0
1
0
2
2
2
0

output:

0 6 6 6 4 4 4 
0 5 5 5 1 1 1 
0 5 5 5 2 2 2 
0 3 3 2 2 2 2 
0 3 4 3 3 3 3 
0 1 1 1 1 1 5 
0 1 1 1 6 1 1 
1 3 4 2 1 6 5 

result:

ok Accepted

Test #8:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

7
0
1
2
0
2
2
2
1
0
2

output:

0 4 4 4 4 1 1 1 
0 5 5 5 5 6 6 6 
0 7 7 7 7 5 5 5 
0 2 2 3 3 1 1 1 
0 7 7 1 1 1 1 1 
0 3 7 3 3 3 3 3 
0 1 1 2 1 1 1 1 
0 4 4 4 4 6 6 5 
0 4 4 4 4 4 4 6 
0 5 5 5 5 6 5 5 
1 3 7 2 1 6 5 4 

result:

ok Accepted

Test #9:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

8
0
1
0
1
0
1
1
2
0
2
1
1
2
2
2

output:

0 4 4 4 4 1 1 1 1 
0 2 2 2 2 3 3 3 3 
0 5 5 5 5 7 7 7 7 
0 6 6 6 6 8 8 8 8 
0 6 6 6 6 2 2 2 2 
0 2 2 1 1 1 1 1 1 
0 3 3 7 7 1 1 1 1 
0 3 3 2 2 1 1 1 1 
0 7 3 3 3 3 3 3 3 
0 1 1 2 1 1 1 1 1 
0 4 4 4 4 4 4 8 8 
0 4 4 4 4 5 5 6 6 
0 4 4 4 4 5 5 4 4 
0 5 5 5 5 6 5 5 5 
0 4 4 4 4 4 4 4 8 
1 3 7 2 1 6 5 4...

result:

ok Accepted

Test #10:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

9
2
0
1
1
1
0
2
0
0
0
2
1
1
2
2
0

output:

0 3 3 3 3 3 8 8 8 8 
0 5 5 5 5 5 1 1 1 1 
0 7 7 7 7 7 2 2 2 2 
0 4 4 4 4 4 6 6 6 6 
0 9 9 9 9 9 7 7 7 7 
0 4 4 4 4 4 7 7 7 7 
0 2 2 2 1 1 1 1 1 1 
0 9 9 9 7 7 1 1 1 1 
0 2 2 7 2 2 2 2 2 2 
0 7 3 3 3 3 3 3 3 3 
0 1 1 1 1 9 1 1 1 1 
0 4 4 4 4 4 8 8 6 6 
0 4 4 4 4 4 5 5 4 4 
0 4 4 4 4 4 5 5 8 8 
0 4 4 ...

result:

ok Accepted

Test #11:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

10
0
1
1
0
2
2
1
2
0
0
0
0
0
1
0
0
2

output:

0 2 2 2 2 2 10 10 10 10 10 
0 5 5 5 5 5 6 6 6 6 6 
0 3 3 3 3 3 7 7 7 7 7 
0 8 8 8 8 8 1 1 1 1 1 
0 9 9 9 9 9 5 5 5 5 5 
0 3 3 3 3 3 4 4 4 4 4 
0 9 9 9 1 1 1 1 1 1 1 
0 7 7 7 9 9 1 1 1 1 1 
0 10 10 7 3 3 3 3 3 3 3 
0 7 3 3 3 3 3 3 3 3 3 
0 1 1 1 9 1 1 1 1 1 1 
0 2 2 2 2 2 2 2 2 4 4 
0 2 2 2 2 2 6 6 6...

result:

ok Accepted

Test #12:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

11
1
1
2
1
0
1
2
1
1
0
0
0
0
1
2
2
0
2
2
2
2

output:

0 3 3 3 3 3 3 5 5 5 5 5 
0 2 2 2 2 2 2 6 6 6 6 6 
0 10 10 10 10 10 10 8 8 8 8 8 
0 7 7 7 7 7 7 3 3 3 3 3 
0 4 4 4 4 4 4 9 9 9 9 9 
0 1 1 1 1 1 1 3 3 3 3 3 
0 3 3 3 3 3 3 11 11 11 11 11 
0 9 9 9 1 1 1 1 1 1 1 1 
0 3 3 3 10 10 10 1 1 1 1 1 
0 5 5 5 7 7 7 1 1 1 1 1 
0 9 9 9 3 3 3 1 1 1 1 1 
0 10 10 3 3...

result:

ok Accepted

Test #13:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

12
0
1
2
0
2
2
0
2
0
2
2
2
2
1
1
2
2
1
0
2
2
2

output:

0 2 2 2 2 2 2 3 3 3 3 3 3 
0 6 6 6 6 6 6 12 12 12 12 12 12 
0 7 7 7 7 7 7 4 4 4 4 4 4 
0 11 11 11 11 11 11 5 5 5 5 5 5 
0 1 1 1 1 1 1 8 8 8 8 8 8 
0 10 10 10 10 10 10 6 6 6 6 6 6 
0 9 9 9 3 3 3 1 1 1 1 1 1 
0 7 7 7 5 5 5 1 1 1 1 1 1 
0 1 1 1 10 10 10 1 1 1 1 1 1 
0 7 7 10 3 3 3 3 3 3 3 3 3 
0 3 7 3 ...

result:

ok Accepted

Test #14:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

13
1
2
2
2
0
2
2
2
2
0
2
2
2
0
2
2
1
2
2
0
0
1
2
2

output:

0 5 5 5 5 5 5 5 7 7 7 7 7 7 
0 10 10 10 10 10 10 10 2 2 2 2 2 2 
0 9 9 9 9 9 9 9 12 12 12 12 12 12 
0 5 5 5 5 5 5 5 8 8 8 8 8 8 
0 6 6 6 6 6 6 6 13 13 13 13 13 13 
0 1 1 1 1 1 1 1 3 3 3 3 3 3 
0 4 4 4 4 4 4 4 11 11 11 11 11 11 
0 1 1 1 1 4 4 4 1 1 1 1 1 1 
0 7 7 7 7 5 5 5 1 1 1 1 1 1 
0 9 9 9 9 10 1...

result:

ok Accepted

Test #15:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

14
0
1
2
0
1
1
1
2
1
0
1
2
1
0
0
2
1
0
2
2
2
2
0
2
0
2
2
0

output:

0 11 11 11 11 11 11 11 14 14 14 14 14 14 14 
0 5 5 5 5 5 5 5 12 12 12 12 12 12 12 
0 10 10 10 10 10 10 10 6 6 6 6 6 6 6 
0 8 8 8 8 8 8 8 1 1 1 1 1 1 1 
0 4 4 4 4 4 4 4 13 13 13 13 13 13 13 
0 2 2 2 2 2 2 2 5 5 5 5 5 5 5 
0 5 5 5 5 5 5 5 3 3 3 3 3 3 3 
0 4 4 4 4 4 4 4 5 5 5 5 5 5 5 
0 14 14 14 14 9 9...

result:

ok Accepted

Test #16:

score: 0
Accepted
time: 1ms
memory: 3764kb

input:

15
0
2
1
2
1
1
1
1
1
0
1
1
0
1
1
2
1
1
2
2
2
2
2
0
0
0
1
1
2
0
0
2
2
1
2
2

output:

0 8 8 8 8 8 8 8 8 4 4 4 4 4 4 4 
0 11 11 11 11 11 11 11 11 2 2 2 2 2 2 2 
0 15 15 15 15 15 15 15 15 10 10 10 10 10 10 10 
0 9 9 9 9 9 9 9 9 5 5 5 5 5 5 5 
0 13 13 13 13 13 13 13 13 15 15 15 15 15 15 15 
0 1 1 1 1 1 1 1 1 15 15 15 15 15 15 15 
0 12 12 12 12 12 12 12 12 14 14 14 14 14 14 14 
0 12 12 1...

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 259ms
memory: 3872kb

input:

975
1
1
1
1
0
1
1
0
0
1
1
1
1
0
0
2
1
1
2
1
0
1
1
2
2
0
1
2
1
1
1
0
1
1
0
1
2
1
2
2
1
2
1
0
1
2
1
2
1
2
1
2
0
1
1
2
0
0
2
1
0
1
1
0
0
0
0
1
0
0
1
1
1
2
1
1
1
1
0
1
1
1
1
1
1
2
2
2
1
2
2
0
1
1
1
1
2
0
1
1
2
2
1
2
2
2
0
1
2
0
2
1
1
1
2
1
2
2
2
2
1
1
1
2
0
1
1
1
2
2
1
1
0
2
1
0
1
1
2
1
0
2
0
0
1
1
2
1
...

output:

0 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 827 82...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 254ms
memory: 3784kb

input:

976
1
1
0
0
1
2
1
1
1
1
2
1
1
1
2
1
1
2
1
1
2
1
1
0
2
1
1
1
2
2
2
1
1
1
1
1
2
0
0
0
2
1
2
0
1
2
1
1
0
2
1
0
0
0
1
1
0
2
0
1
0
1
2
1
1
1
0
1
1
1
0
1
0
0
2
0
2
1
0
2
1
1
0
0
1
1
2
2
1
1
0
2
1
1
1
2
0
1
1
0
2
1
1
2
1
0
1
0
2
0
1
1
1
2
1
1
0
2
1
1
0
1
0
2
1
1
0
1
1
2
1
1
0
1
1
1
1
0
1
2
2
1
2
2
0
1
2
2
...

output:

0 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 184 18...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 233ms
memory: 3912kb

input:

977
2
1
1
1
1
1
1
1
1
1
0
0
2
1
1
1
1
1
1
1
0
0
1
2
1
2
1
1
1
1
1
2
2
1
1
1
2
1
0
0
1
1
0
1
1
1
2
0
1
2
2
1
1
2
0
1
1
0
2
1
2
2
0
0
1
1
1
2
2
1
1
1
1
2
2
1
1
1
0
1
2
0
0
1
0
2
1
1
1
2
0
2
0
1
1
0
1
1
0
1
0
2
2
2
1
2
2
2
0
2
1
1
1
1
1
1
1
1
0
1
2
1
2
1
2
1
0
1
2
1
1
1
0
0
1
0
1
1
1
2
1
0
2
1
1
1
1
1
...

output:

0 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 720 72...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 241ms
memory: 3916kb

input:

978
1
0
1
0
1
1
2
1
1
0
1
0
1
1
0
1
1
2
1
1
2
1
0
0
1
0
1
1
1
0
2
0
1
1
1
2
1
0
1
1
2
1
2
2
1
1
2
1
1
1
1
0
2
2
1
1
1
2
1
1
0
1
1
2
1
1
0
2
1
1
1
0
1
1
1
1
1
1
1
0
0
0
1
1
1
1
2
1
0
0
1
1
0
0
1
1
0
0
1
0
1
1
2
0
0
1
2
1
1
2
0
2
1
0
1
1
0
0
1
1
0
0
2
0
1
1
1
1
1
2
0
1
0
0
0
1
0
1
2
1
1
1
1
1
2
1
1
1
...

output:

0 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 972 97...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 223ms
memory: 3808kb

input:

979
0
0
0
0
1
0
1
1
1
1
0
1
2
1
1
1
1
2
1
0
0
1
1
1
1
0
1
2
0
1
2
2
1
0
2
1
1
1
1
0
2
1
1
1
2
1
0
1
0
0
1
1
0
1
0
2
0
1
1
2
2
1
0
1
1
1
0
1
2
1
1
1
1
2
0
2
1
1
2
1
1
2
1
1
1
0
0
1
1
1
1
2
1
1
0
2
0
1
2
1
0
1
0
2
2
0
1
0
0
1
0
0
1
1
1
0
1
2
2
1
0
2
1
1
1
1
1
0
1
1
1
0
0
2
1
2
0
1
0
1
1
0
1
1
1
0
2
1
...

output:

0 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 643 64...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 257ms
memory: 3860kb

input:

980
1
1
2
2
1
1
2
1
0
2
2
1
2
0
0
0
1
1
2
1
0
1
0
2
0
1
1
1
0
1
2
1
0
0
2
2
0
1
1
1
1
1
2
0
2
1
1
2
1
2
1
1
0
1
1
0
1
2
2
1
1
1
1
1
0
1
1
0
1
1
1
1
2
1
1
1
2
0
0
1
1
0
1
0
2
1
1
1
1
1
1
1
0
1
1
2
1
2
1
1
2
2
1
0
2
1
2
2
0
1
0
2
1
1
0
2
1
2
1
1
2
0
0
1
1
2
1
2
1
2
2
1
1
2
0
1
2
1
1
0
1
1
1
1
2
2
1
1
...

output:

0 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 12...

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 260ms
memory: 3856kb

input:

981
2
0
2
1
0
0
1
0
1
2
2
1
1
1
2
1
1
1
0
1
0
1
2
2
0
1
1
2
2
1
1
1
1
1
1
1
2
1
0
0
1
2
1
2
2
2
1
1
2
1
1
1
1
2
1
1
1
1
2
0
1
1
1
0
1
2
0
2
0
1
1
2
0
0
1
1
1
0
2
0
1
1
2
1
2
0
2
2
0
2
1
1
1
1
0
2
0
2
2
0
2
1
1
0
1
1
0
0
2
1
0
0
1
2
1
1
1
1
2
0
0
0
2
0
2
2
1
2
1
0
2
1
1
2
0
1
0
1
1
2
2
1
1
0
2
2
2
1
...

output:

0 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 55...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 226ms
memory: 3880kb

input:

982
1
2
0
2
2
1
1
1
0
0
2
0
0
2
0
0
1
0
1
0
1
1
2
1
1
1
0
1
2
0
1
1
1
0
0
1
1
1
1
2
1
0
0
0
1
0
2
1
0
1
1
0
1
0
2
0
1
0
1
1
2
1
1
0
1
1
2
0
1
1
1
0
1
1
0
0
1
2
0
1
0
1
2
1
2
0
0
2
0
0
2
0
0
0
1
1
1
1
2
1
1
2
0
1
0
2
0
2
1
1
2
0
1
1
1
2
1
2
0
2
1
1
1
1
0
2
1
1
2
0
0
1
1
2
1
1
0
1
1
1
2
1
2
1
2
2
1
2
...

output:

0 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 735 73...

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 246ms
memory: 4036kb

input:

983
0
1
1
2
2
1
0
2
1
1
0
2
1
0
2
1
1
1
0
1
1
2
2
1
1
0
2
0
2
1
0
0
1
1
1
1
1
1
2
1
1
2
0
2
1
2
2
1
0
1
1
0
2
1
2
1
1
1
2
0
0
2
2
2
2
1
2
1
1
1
1
1
0
1
2
1
1
1
2
1
0
1
1
1
0
1
2
0
1
1
2
2
0
2
1
1
0
1
1
1
1
2
0
0
0
1
1
1
2
1
2
1
1
1
0
0
0
1
0
0
1
2
1
0
1
0
1
1
1
2
1
0
2
2
1
1
1
2
1
2
1
1
2
1
1
0
1
1
...

output:

0 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456 45...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 246ms
memory: 3916kb

input:

984
1
2
1
0
2
0
1
1
1
0
1
0
1
1
2
2
1
1
1
2
2
1
2
1
0
2
1
2
1
1
1
0
1
1
1
2
1
1
1
1
2
2
1
1
1
0
1
1
0
1
1
1
0
2
2
2
2
2
1
1
0
1
1
1
1
0
1
0
1
2
1
1
0
1
2
1
1
1
1
0
1
0
1
1
0
1
0
1
2
0
2
2
1
0
2
0
1
1
1
1
1
2
1
0
2
0
2
1
1
1
1
2
1
1
1
1
0
0
1
1
1
1
1
0
0
2
2
1
2
1
1
1
1
1
0
1
2
1
2
0
1
1
1
1
0
1
1
1
...

output:

0 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 363 36...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 263ms
memory: 3892kb

input:

985
0
2
2
2
2
1
0
1
1
1
0
1
0
2
1
1
1
1
1
1
2
0
2
1
2
1
1
1
1
1
2
2
1
0
1
1
1
2
1
2
0
1
1
1
1
2
1
0
2
2
0
1
0
2
2
0
0
2
1
2
0
0
1
1
1
0
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
0
2
1
0
1
0
2
1
0
1
1
1
1
2
1
0
2
1
1
1
0
1
2
1
2
2
0
1
2
1
0
1
1
1
2
1
0
2
1
1
1
1
1
1
1
0
1
0
1
1
1
1
2
1
2
0
0
1
1
1
1
1
2
1
0
1
1
...

output:

0 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 60...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 260ms
memory: 4100kb

input:

986
2
1
0
1
1
1
0
1
2
1
1
2
1
0
0
1
2
2
0
1
1
0
1
2
1
2
0
0
1
2
2
2
1
1
1
0
1
1
1
1
1
1
1
1
1
0
0
1
2
1
1
2
2
1
2
1
0
0
1
1
0
1
0
2
0
2
0
0
2
1
1
1
2
2
2
0
0
2
0
0
1
1
1
0
0
0
1
1
1
2
1
1
2
1
1
1
2
0
2
0
0
1
1
2
0
2
0
2
2
0
1
1
1
0
1
2
2
1
2
0
2
2
1
1
1
2
1
1
1
2
2
2
1
1
0
2
1
1
2
2
1
1
1
2
0
1
1
1
...

output:

0 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 1...

result:

ok Accepted

Test #29:

score: 0
Accepted
time: 231ms
memory: 3796kb

input:

987
2
1
1
2
0
1
1
0
1
2
1
1
1
0
2
1
1
1
2
0
2
0
0
1
2
0
1
1
2
1
1
1
1
1
1
2
1
2
1
1
1
1
0
1
1
1
0
2
0
1
1
1
0
0
0
2
1
1
1
2
1
2
1
2
0
0
2
0
0
2
2
0
1
1
1
1
0
1
0
1
2
2
1
1
1
1
1
0
1
0
0
1
1
2
2
1
2
2
1
1
0
0
1
2
1
1
2
1
1
0
1
2
1
2
2
1
1
1
0
1
2
1
1
0
1
0
1
1
1
2
1
2
1
1
1
2
1
1
2
1
1
0
0
1
1
1
1
1
...

output:

0 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 86...

result:

ok Accepted

Test #30:

score: 0
Accepted
time: 233ms
memory: 4068kb

input:

988
0
0
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
2
1
0
0
1
0
0
0
2
2
0
1
1
0
2
1
0
1
0
0
1
0
2
1
1
1
0
2
2
1
2
0
1
1
1
0
1
1
1
1
1
1
2
2
1
0
1
2
1
1
1
0
1
2
1
1
0
1
1
2
0
0
0
2
1
0
1
0
1
1
2
2
0
1
1
2
2
1
1
2
1
1
1
1
1
0
1
0
2
1
1
0
1
1
2
1
1
0
0
1
1
0
0
1
1
1
1
2
0
1
1
1
1
1
1
0
2
1
1
1
2
1
1
0
0
0
1
1
2
...

output:

0 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 242 24...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 219ms
memory: 3860kb

input:

989
1
1
1
2
1
1
0
1
1
2
1
1
1
2
1
1
2
1
1
0
0
1
2
0
2
1
2
0
2
1
0
2
1
1
1
1
1
0
1
1
0
1
0
2
1
1
2
0
1
1
1
2
2
2
1
1
2
2
1
1
1
1
2
0
2
1
1
0
1
2
1
1
2
2
1
0
2
1
1
0
0
2
2
2
0
1
0
1
1
2
0
0
0
0
1
2
1
1
1
0
0
0
2
1
1
1
0
1
1
1
0
2
2
2
2
1
0
2
1
1
1
1
1
1
2
1
0
0
1
1
2
1
2
1
1
2
1
1
1
1
2
0
0
1
1
2
0
2
...

output:

0 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 6...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 260ms
memory: 3864kb

input:

990
1
2
0
2
0
1
1
2
1
1
1
1
1
0
2
1
2
1
1
2
1
2
2
2
1
1
0
1
0
1
1
0
2
1
1
1
1
2
1
2
2
1
1
1
2
1
0
1
1
2
1
1
1
1
1
2
1
1
1
1
2
0
1
2
2
1
2
0
0
1
1
2
1
0
0
2
1
0
1
1
1
0
0
0
0
2
2
1
0
0
2
0
1
1
1
0
0
0
1
1
0
2
1
0
1
1
2
1
2
1
2
1
0
1
1
1
0
1
2
2
1
1
1
0
1
2
1
1
1
0
0
0
0
1
1
2
1
0
1
1
1
2
1
2
0
0
1
2
...

output:

0 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 84...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 229ms
memory: 4080kb

input:

991
0
1
1
2
1
1
0
0
1
2
1
0
1
1
1
1
1
0
1
1
1
2
1
1
0
0
0
0
1
1
1
0
1
1
1
1
0
1
1
0
0
2
1
1
1
1
1
2
0
1
0
0
2
1
1
1
1
1
1
1
2
0
0
1
1
1
0
1
2
0
0
1
1
2
2
2
1
1
1
1
2
0
0
1
0
1
0
0
1
1
2
0
1
1
0
1
1
1
1
1
2
1
1
1
0
1
2
1
1
0
0
1
1
1
0
1
1
0
1
0
2
2
1
0
1
1
2
2
0
1
2
1
1
1
0
1
1
0
2
2
0
1
2
2
1
1
0
2
...

output:

0 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 206 20...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 236ms
memory: 4012kb

input:

992
0
1
1
1
0
1
1
0
0
1
2
1
2
1
2
1
1
1
1
1
1
1
2
1
0
2
1
1
1
2
1
1
2
0
1
2
1
1
1
0
2
1
0
0
2
2
1
2
1
0
0
0
0
1
1
1
2
1
0
1
0
2
2
2
0
0
1
1
0
1
2
2
0
0
1
0
1
1
2
0
2
1
0
1
0
1
0
0
1
0
2
1
1
1
1
0
1
1
1
1
1
0
1
0
2
1
0
1
0
0
0
2
1
1
2
2
1
0
1
0
2
1
1
0
1
2
0
0
2
1
0
1
1
1
0
2
2
1
1
2
1
1
0
2
2
1
2
0
...

output:

0 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 954 95...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 246ms
memory: 3872kb

input:

993
1
0
1
1
2
1
0
0
1
1
1
1
0
2
1
1
1
1
2
2
0
1
1
1
0
2
1
0
0
2
1
0
0
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
0
2
1
2
2
1
2
1
2
2
1
0
1
1
2
1
2
0
1
0
2
1
1
1
0
2
2
2
1
2
1
1
1
1
1
1
0
0
2
1
0
1
1
2
2
2
0
1
2
2
0
1
1
2
0
1
1
2
0
1
1
0
0
2
0
1
1
2
1
2
0
2
1
0
1
1
1
1
2
0
2
1
2
1
2
2
1
1
1
1
1
1
1
1
0
1
0
...

output:

0 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 378 37...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 274ms
memory: 3872kb

input:

994
1
1
1
2
1
2
0
2
1
1
0
1
2
1
1
1
0
0
2
0
1
0
1
2
1
1
0
1
2
1
2
2
2
1
1
2
1
0
2
0
0
1
1
2
2
0
2
0
1
1
1
1
0
2
1
2
2
1
0
2
1
1
1
1
1
1
1
2
0
1
2
1
0
1
2
1
1
1
1
1
0
0
0
2
1
1
0
1
2
2
2
0
2
1
1
0
1
2
0
0
1
2
2
1
2
1
0
1
1
0
2
0
1
1
1
1
0
1
2
1
1
1
1
0
1
1
1
1
0
2
1
1
1
2
0
1
0
1
1
2
0
1
0
2
1
1
0
1
...

output:

0 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 2...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 262ms
memory: 4080kb

input:

995
1
0
1
1
2
2
2
2
0
1
1
0
1
1
1
0
1
0
2
2
1
1
0
1
1
0
0
1
0
1
2
1
2
1
1
1
2
1
1
2
0
1
1
1
1
2
2
2
1
1
1
2
2
0
2
2
2
1
0
2
1
1
0
2
0
0
2
1
1
0
0
1
0
0
1
1
0
1
2
1
2
1
2
0
1
1
1
1
1
0
0
0
2
1
1
0
1
1
1
2
2
1
1
1
2
2
1
2
1
1
0
0
1
1
0
2
0
1
0
2
0
1
2
0
1
0
1
1
0
1
2
2
0
0
0
0
0
1
0
0
1
1
0
0
1
0
0
2
...

output:

0 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 244 24...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 264ms
memory: 3868kb

input:

996
0
2
1
0
1
0
1
0
2
1
0
1
2
1
1
1
1
0
2
1
0
1
0
0
1
1
1
2
1
0
0
0
1
0
1
1
1
1
1
2
1
2
1
1
0
2
2
1
2
1
2
0
2
2
0
2
2
1
1
1
1
1
0
0
1
1
2
1
1
1
1
1
1
1
2
0
1
0
1
1
2
2
1
2
1
1
1
0
2
1
0
1
1
1
0
0
2
1
2
2
1
1
1
2
0
1
2
2
1
1
1
2
2
1
0
1
1
1
2
0
2
1
0
1
2
1
1
1
0
1
1
1
1
2
2
2
0
2
1
1
2
2
1
0
2
1
1
0
...

output:

0 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 270 27...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 273ms
memory: 3852kb

input:

997
2
1
2
1
1
1
1
1
1
1
0
2
0
1
1
0
1
0
0
1
2
1
1
1
0
1
0
1
2
2
1
0
1
2
1
1
1
0
1
2
1
1
2
2
1
1
0
0
1
1
1
2
1
0
1
1
2
1
1
0
1
1
2
1
1
0
1
1
1
1
0
2
1
1
2
1
1
1
2
2
1
1
1
0
2
2
1
1
2
1
0
1
1
0
1
0
2
0
0
1
0
0
1
0
1
2
0
2
1
1
1
1
2
1
1
1
1
1
1
0
2
1
0
1
1
0
2
1
1
2
0
0
1
1
1
0
0
2
2
2
1
1
2
0
1
2
0
0
...

output:

0 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 986 98...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 260ms
memory: 3868kb

input:

998
2
0
0
1
1
1
2
2
1
1
0
0
1
2
2
1
1
1
1
2
0
1
1
0
1
1
1
2
2
1
1
2
0
0
1
1
2
0
0
1
2
2
1
0
1
1
1
2
2
1
1
1
1
2
1
2
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
0
0
1
1
0
1
1
1
0
2
1
0
1
1
1
2
1
0
0
0
1
0
0
1
1
1
0
1
1
0
0
1
2
2
1
1
0
1
2
0
1
1
2
0
1
1
2
1
2
1
2
1
1
2
1
0
1
0
2
1
0
0
1
2
0
2
0
1
...

output:

0 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 816 81...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 269ms
memory: 3808kb

input:

999
0
0
1
1
1
2
1
0
0
2
0
1
0
2
2
2
2
0
0
1
0
2
1
1
1
2
1
1
1
2
2
2
1
0
1
1
0
1
1
1
1
0
2
0
2
0
1
1
0
2
0
1
2
2
2
0
2
2
1
1
1
1
1
1
0
1
1
1
2
1
2
2
1
1
1
1
1
2
1
0
1
0
1
2
1
1
1
2
1
1
2
1
1
1
2
0
1
1
0
2
2
1
0
1
2
0
0
0
2
2
0
1
0
1
1
1
0
2
1
1
1
0
2
1
2
1
2
1
0
1
1
0
0
1
1
1
1
0
2
1
2
1
1
1
0
1
0
1
...

output:

0 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 358 35...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed