QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741347#9432. PermutationforgotmyhandleAC ✓326ms3852kbC++142.1kb2024-11-13 14:09:042024-11-13 14:09:05

Judging History

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

  • [2024-11-13 14:09:05]
  • 评测
  • 测评结果:AC
  • 用时:326ms
  • 内存:3852kb
  • [2024-11-13 14:09:04]
  • 提交

answer

#include <iostream>
#include <random>
#include <vector>
using namespace std;
random_device rd;
mt19937 mtrand(rd());
int n;
int ans[1005];
int f[1005];
void ini(int x) { for (; x; --x) f[x] = x; }
int getf(int x) { return (f[x] == x ? x : (f[x] = getf(f[x]))); }
int bel[1005];
int ask(int k, int x, int y) {
    cout << "0 ";
    for (int i = 1; i <= k; i++) cout << x << " ";
    for (int i = 1; i <= n - k; i++) cout << y << " ";
    cout << endl;
    cin >> k;
    return k;
}
void Solve(int l, int r, vector<int> S) {
    // cout << l << " " << r << "\n";
    // for (int i : S) cout << i << " ";
    // cout << endl;
    if (l == r) {
        ans[l] = S[0];
        return;
    }
    int mid = (l + r) >> 1;
    ini(n);
    vector<int> v[2], tmp = S;
    int c0 = 0, c1 = 0;
    while (S.size()) {
        int x, y;
        if ((int)S.size() == 1) {
            x = S[0];
            if (!c0 || !c1) 
                bel[x] = !!c0;
            else 
                bel[x] = !ask(mid, x, c0);
            break;
        }
        x = mtrand() % S.size(), y = mtrand() % ((int)S.size() - 1);
        y += (y >= x);
        int t = ask(mid, S[x], S[y]);
        if (t == 0) 
            bel[c1 = S[x]] = 1, bel[c0 = S[y]] = 0, S.erase(S.begin() + max(x, y)), S.erase(S.begin() + min(x, y));
        else if (t == 2) 
            bel[c0 = S[x]] = 0, bel[c1 = S[y]] = 1, S.erase(S.begin() + max(x, y)), S.erase(S.begin() + min(x, y));
        else {
            f[getf(S[x])] = S[y];
            S.erase(S.begin() + x);
        }
        // cout << "ASDf\n";
        // for (auto s : S) cout << s << " ";
        // cout << endl;
    }
    // for (auto x : tmp) cout << x << " " << getf(x) << " " << bel[getf(x)] << " x" << endl;
    for (auto x : tmp) v[bel[getf(x)]].emplace_back(x);
    Solve(l, mid, v[0]);
    Solve(mid + 1, r, v[1]);
}
int main() {
    vector<int> v;
    cin >> n;
    for (int i = 1; i <= n; i++) v.emplace_back(i);
    Solve(1, n, v);
    cout << "1 ";
    for (int i = 1; i <= n; i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
0
2
1
2
1
0
0

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 322ms
memory: 3840kb

input:

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

output:

0 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 239 23...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
0
1
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
0
0
0

output:

0 4 4 2 2 
0 1 1 3 3 
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: 3608kb

input:

6
0
2
2
0
1
0
0
1
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
0
0
0
1
0
0
0
2
1
0
0

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 283ms
memory: 3640kb

input:

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

output:

0 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 934 93...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 498 49...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 517 51...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 275 27...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 296ms
memory: 3512kb

input:

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

output:

0 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 14...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 979 97...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 324 32...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 902 90...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 3...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 85...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 703 70...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 12...

result:

ok Accepted

Test #29:

score: 0
Accepted
time: 287ms
memory: 3612kb

input:

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

output:

0 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 852 85...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 87...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 292ms
memory: 3640kb

input:

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

output:

0 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 809 80...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 287ms
memory: 3516kb

input:

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

output:

0 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 952 95...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 306ms
memory: 3564kb

input:

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

output:

0 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 937 93...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 281ms
memory: 3848kb

input:

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

output:

0 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 304 30...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 905 90...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 326ms
memory: 3512kb

input:

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

output:

0 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 474 47...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 236 23...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 304ms
memory: 3640kb

input:

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

output:

0 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 176 17...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 319ms
memory: 3628kb

input:

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

output:

0 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 11...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 293ms
memory: 3512kb

input:

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

output:

0 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 581 58...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 89...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed