QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#610921#9432. Permutationyukino_yukinoshitaAC ✓281ms3880kbC++142.7kb2024-10-04 18:02:512024-10-04 18:02:56

Judging History

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

  • [2024-10-04 18:02:56]
  • 评测
  • 测评结果:AC
  • 用时:281ms
  • 内存:3880kb
  • [2024-10-04 18:02:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
namespace Wilson_Inversion {
  void main();
}
int main() {
  return Wilson_Inversion::main(), 0;
}
namespace Wilson_Inversion {
  const int N = 1010;
  int f[N], ans[N];
  int n;
  int find(int x) {
    return f[x] == x ? x : (f[x] = find(f[x]));
  }
  int bel[N];
  void sol(vector<int> x, int l, int r) {
    if (l == r) {
      ans[l] = x[0];
      return;
    }
    vector<int> res = x, ld, rd;
    int mid = (l + r) >> 1;
    for (int i : x) f[i] = i, bel[i] = 0;
    while (res.size()) {
      if (res.size() == 1) {
        int t = 0;
        for (int i : x) if (bel[find(i)]) {
          t = i;
          break;
        }
        cout << "0 ";
        for (int i = 1; i < l; ++i) cout << res[0] << " ";
        for (int i = l; i <= mid; ++i) cout << res[0] << " ";
        for (int i = mid + 1; i <= r; ++i) cout << t << " ";
        for (int i = r + 1; i <= n; ++i) cout << res[0] << " ";
        cout << '\n';
        cout << flush;
        int ti;
        cin >> ti;
        if (bel[find(t)] == 1) {
          if (ti == 1) bel[res[0]] = 1;
          else bel[res[0]] = 2;
        } else if(bel[find(t)] == 2) {
          if (ti == 2) bel[res[0]] = 1;
          else bel[res[0]] = 2;
        }
        break;
      }
      vector<int> t;
      while (res.size() > 1) {
        int x = res.back();
        res.pop_back();
        int y = res.back();
        res.pop_back();
        cout << "0 ";
        for (int i = 1; i < l; ++i) cout << y << " ";
        for (int i = l; i <= mid; ++i) cout << x << " ";
        for (int i = mid + 1; i <= r; ++i) cout << y << " ";
        for (int i = r + 1; i <= n; ++i) cout << y << " ";
        cout << '\n';
        cout << flush;
        int ti;
        cin >> ti;
        if (ti == 0) bel[x] = 2, bel[y] = 1;
        else if (ti == 2) bel[x] = 1, bel[y] = 2;
        else {
          f[y] = x;
          bel[x] = 0;
          t.push_back(x);
        }
      }
      if (res.size() == 1) t.push_back(res[0]);
      res = t;
    }
    for (int i : x) {
      if (bel[find(i)] == 1) ld.push_back(i);
      else rd.push_back(i);
    }
    sol(ld, l, mid);
    sol(rd, mid + 1, r);
  }
  mt19937 seed(chrono::system_clock().now().time_since_epoch().count());
  void solve() {
    cin >> n;
    vector<int> num;
    for (int i = 1; i <= n; ++i) num.push_back(i);
    shuffle(num.begin(), num.end(), seed);
    sol(num, 1, n);
    cout << "1 ";
    for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
    cout << '\n';
    cout << flush;
  }
  void main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int T = 1;
    // cin >> T;
    while (T--) solve();
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
0
2
2
2
2
0
0

output:

0 5 5 5 4 4 
0 2 2 2 1 1 
0 3 3 3 1 1 
0 4 4 2 2 2 
0 3 3 2 3 3 
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: 269ms
memory: 3604kb

input:

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

output:

0 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 858 85...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
1
0
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
0
0
2
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
1
2
2
0
1
2
1
0
2

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

0 8 8 8 8 2 2 2 2 
0 4 4 4 4 6 6 6 6 
0 5 5 5 5 7 7 7 7 
0 3 3 3 3 1 1 1 1 
0 3 3 3 3 4 4 4 4 
0 2 2 7 7 7 7 7 7 
0 3 3 1 1 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 8 8 4 4 
0 5 5 5 5 6 6 5 5 
0 8 8 8 8 6 6 8 8 
0 5 5 5 5 6 5 5 5 
0 4 4 4 4 4 4 8 4 
1 3 7 2 1 6 5 4 8 

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 64...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 506 50...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 428 42...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 272ms
memory: 3668kb

input:

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

output:

0 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 804 80...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 611 61...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 899 89...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 4...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 50...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 71...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 761 76...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 253ms
memory: 3660kb

input:

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

output:

0 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 900 90...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 390 39...

result:

ok Accepted

Test #29:

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

input:

987
1
1
0
1
2
1
1
1
0
0
1
0
0
0
2
0
0
0
1
0
0
0
1
2
1
0
0
2
1
1
0
2
1
0
0
0
2
0
0
1
0
1
0
0
2
1
2
1
1
1
0
1
0
2
1
1
1
1
0
0
1
1
1
1
1
2
1
2
1
2
2
1
0
1
0
0
1
0
0
2
2
1
2
1
1
0
2
1
0
0
0
2
0
2
1
1
1
2
1
1
1
1
0
2
2
0
0
1
1
1
2
0
2
1
1
2
2
0
1
2
1
0
1
2
1
1
1
1
2
1
1
1
1
1
2
2
0
2
0
2
1
2
2
0
2
1
0
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 #30:

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

input:

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

output:

0 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 77 7...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 546 54...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 734 73...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 647 64...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 271ms
memory: 3648kb

input:

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

output:

0 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 217 21...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 244ms
memory: 3664kb

input:

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

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 #36:

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

input:

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

output:

0 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 157 15...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 615 61...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 245ms
memory: 3644kb

input:

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

output:

0 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 792 79...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 505 50...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 13...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 256ms
memory: 3604kb

input:

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

output:

0 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 941 94...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed