QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745828#9432. PermutationchroneZAC ✓312ms3888kbC++172.2kb2024-11-14 11:50:062024-11-14 11:50:06

Judging History

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

  • [2024-11-14 11:50:06]
  • 评测
  • 测评结果:AC
  • 用时:312ms
  • 内存:3888kb
  • [2024-11-14 11:50:06]
  • 提交

answer

// Such a destiny was not desired.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
constexpr int N = 1e3 + 5;
int n, p[N];

inline int ask(int m, int x, int y) {
  cout << 0 << " ";
  for(int i = 1; i <= m; i++) cout << x << " ";
  for(int i = m + 1; i <= n; i++) cout << y << " ";
  cout << endl;
  int ret; cin >> ret;
  return ret;
}

struct DUS {
  int f[N];
  inline void init(int n) {iota(f + 1, f + n + 1, 1);}
  inline int find(int x) {while(x != f[x]) x = f[x] = f[f[x]]; return x;}
  inline void merge(int x, int y) {
    x = find(x), y = find(y);
    f[y] = x;
  }
} D;

int g[N];
void solve(int l, int r, vector<int> S) {
  if(l == r) return p[l] = S[0], void();
  int m = l + r >> 1;
  vector<int> o = S;

  vector<int> L, R;
  while(S.size() > 1) {
    int itx = rng() % S.size(), ity = rng() % S.size();
    while(itx == ity) itx = rng() % S.size(), ity = rng() % S.size();
    int x = S[itx], y = S[ity];

    int e = ask(m, x, y);
    if(e == 0) {
      g[x] = 1, g[y] = 0;
      if(itx < ity) swap(itx, ity);
      S.erase(S.begin() + itx), S.erase(S.begin() + ity);
    } else if(e == 2) {
      g[x] = 0, g[y] = 1;
      if(itx < ity) swap(itx, ity);
      S.erase(S.begin() + itx), S.erase(S.begin() + ity);
    } else {
      D.merge(x, y);
      S.erase(S.begin() + ity);
    }
  }
  if(S.size() == 1) {
    int x = -1;
    for(auto y : o) {
      if(D.find(y) != S[0]) {
        x = y;
        break;
      }
    }
    int e = ask(m, S[0], x);
    if(e == 0) g[S[0]] = 1;
    else if(e == 2) g[S[0]] = 0;
    else D.merge(x, S[0]);
  }

  for(auto x : o) {
    g[x] = g[D.find(x)];
    if(g[x] == 0) L.push_back(x);
    else R.push_back(x);
  }
  for(auto x : o) {
    D.f[x] = x;
  }
  solve(l, m, L);
  solve(m + 1, r, R);
}

int main() {
  // ios::sync_with_stdio(false);
  // cin.tie(nullptr), cout.tie(nullptr);
  
  cin >> n;
  vector<int> U(n);
  iota(U.begin(), U.end(), 1);
  D.init(n);
  solve(1, n, U);
  cout << 1 << " ";
  for(int i = 1; i <= n; i++) cout << p[i] << " ";
  cout << endl;
}

详细

Test #1:

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

input:

5
0
2
2
1
0
0
0

output:

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

input:

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

output:

0 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 674 67...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

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: 3560kb

input:

4
0
0
0
0

output:

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

input:

6
0
0
0
0
2
0
0
1
2

output:

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

result:

ok Accepted

Test #8:

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

input:

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

output:

0 5 5 5 5 3 3 3 
0 7 7 7 7 6 6 6 
0 2 2 2 2 1 1 1 
0 4 4 4 4 2 2 2 
0 2 2 3 3 3 3 3 
0 7 7 1 1 1 1 1 
0 3 7 7 7 7 7 7 
0 1 1 1 2 2 2 2 
0 4 4 4 4 4 4 5 
0 6 6 6 6 6 6 4 
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: 3864kb

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 269 26...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 294ms
memory: 3576kb

input:

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

output:

0 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 940 94...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 275ms
memory: 3888kb

input:

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

output:

0 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 760 76...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 344 34...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 24...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 147 14...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 401 40...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 10...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 232 23...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 628 62...

result:

ok Accepted

Test #27:

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

input:

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

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

score: 0
Accepted
time: 289ms
memory: 3580kb

input:

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

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

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

input:

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

output:

0 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 42...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 16...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 280ms
memory: 3580kb

input:

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

output:

0 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 329 32...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 551 55...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 163 16...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 7...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 577 57...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 307ms
memory: 3652kb

input:

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

output:

0 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 252 25...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 297ms
memory: 3584kb

input:

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

output:

0 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 778 77...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 305ms
memory: 3548kb

input:

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

output:

0 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 283 28...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 72...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 312ms
memory: 3708kb

input:

998
0
0
2
1
2
2
1
1
1
0
1
0
0
1
1
0
1
1
1
1
1
1
1
2
0
1
2
1
0
1
0
1
0
2
1
1
0
2
1
1
1
1
0
1
1
0
1
1
2
2
1
0
0
0
2
0
2
0
2
1
2
2
1
0
0
1
2
2
2
1
1
2
1
1
0
1
1
2
0
1
0
1
1
2
1
1
1
1
1
1
1
0
2
2
2
1
1
2
1
1
2
1
1
1
1
2
1
2
0
1
2
0
1
1
0
2
2
0
1
1
0
1
1
0
0
0
2
0
1
0
0
2
2
1
0
1
1
1
1
2
1
1
1
1
0
2
0
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 #41:

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

input:

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

output:

0 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 679 67...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed