QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#744024#9432. Permutationlzc0115AC ✓295ms3864kbC++141.4kb2024-11-13 20:37:112024-11-13 20:37:15

Judging History

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

  • [2024-11-13 20:37:15]
  • 评测
  • 测评结果:AC
  • 用时:295ms
  • 内存:3864kb
  • [2024-11-13 20:37:11]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<vector>
#include<random>

using namespace std;

int n, a[1010], f[1010], sz[1010], cl, cr;
bool b[1010];

mt19937 Rand(time(0));

vector<int> S;

int F(int x){
  return (f[x] ? f[x] = F(f[x]) : x);
}

int Ask(int mid, int x, int y){
  int c = 0;
  cout << "0 ";
  for(int i = 1; i <= mid; i++) cout << x << " ";
  for(int i = mid + 1; i <= n; i++) cout << y << " ";
  cout << endl;
  cin >> c;
  if(c == 1){
    f[x] = y, sz[y] += sz[x];
    return 1;
  }
  if(c == 2) cl += sz[x], cr += sz[y], b[y] = 1;
  else cl += sz[y], cr += sz[x], b[x] = 1;
  return 2;
}

void Solve(int l, int r){
  if(l == r) return;
  // shuffle(a + l, a + r + 1, Rand);
  for(int i = l; i <= r; i++) b[a[i]] = f[a[i]] = 0, sz[a[i]] = 1;
  cl = cr = 0;
  int p = l, mid = (l + r) >> 1;
  while(p < r) p += Ask(mid, a[p], a[p + 1]);
  if(p == r) b[a[p]] = (cl == mid - l + 1);
  for(int i = l; i <= r; i++){
    b[a[i]] = b[F(a[i])];
  }
  for(int i = l, j = r; i < j; ){
    while(i < j && !b[a[i]]) i++;
    while(i < j && b[a[j]]) j--;
    swap(a[i], a[j]);
  }
  Solve(l, mid), Solve(mid + 1, r);
}

int main(){
  cin >> n;
  for(int i = 1; i <= n; i++) a[i] = i;
  shuffle(a + 1, a + n + 1, Rand);
  Solve(1, n);
  cout << 1 << " ";
  for(int i = 1; i <= n; i++){
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}

详细

Test #1:

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

input:

5
1
1
2
0
2
2

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 290ms
memory: 3768kb

input:

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

output:

0 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 25...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
0
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
0
0
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
2
0
2
2
0
0
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
0
1
2
2
1
0
0
0
0
2

output:

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

result:

ok Accepted

Test #9:

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

input:

8
0
0
2
2
0
0
2
2
0
0
0
2

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 302 30...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 384 38...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 316 31...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 788 78...

result:

ok Accepted

Test #21:

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

input:

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

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

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

input:

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

output:

0 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 215 21...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 97...

result:

ok Accepted

Test #24:

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

input:

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

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

score: 0
Accepted
time: 278ms
memory: 3768kb

input:

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

output:

0 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 207 20...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 819 81...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 258 25...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 15...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 605 60...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 387 38...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 11...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 657 65...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 971 97...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 323 32...

result:

ok Accepted

Test #35:

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

input:

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

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

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

input:

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

output:

0 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 85...

result:

ok Accepted

Test #37:

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

input:

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

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

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

input:

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

output:

0 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 570 57...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 607 60...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 2...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 835 83...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed