QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621791#9432. PermutationGrand_ElfAC ✓259ms3884kbC++171.3kb2024-10-08 17:00:402024-10-08 17:00:41

Judging History

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

  • [2024-10-08 17:00:41]
  • 评测
  • 测评结果:AC
  • 用时:259ms
  • 内存:3884kb
  • [2024-10-08 17:00:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

mt19937 rnd(time(0) ^ (unsigned long long)(new char));

const int N = 1005;

int n, a[N], b[N], ans[N];

int query(int l, int r, int x, int y) {
	int mid = l + r >> 1, res = 0;
	cout << 0 << ' ';
	for (int i = 1; i <= n; i++) {
		cout << (i > mid && i <= r ? y : x) << ' ';
	}
	cout << endl;
	cin >> res;
	return res;
}

void solve(int l, int r) {
	if (l == r) {
		return;
	}
	int mid = l + r >> 1;
	for (int i = l, j = l, k = mid + 1; i <= r; i++) {
		if (j > mid) {
			b[k++] = a[i];
			continue;
		} else if (k > r) {
			b[j++] = a[i];
			continue;
		}
		for (int t = i + 1; t <= r; t++) {
			int res = query(l, r, a[i], a[t]);
			if (res == 2) {
				for (int p = i; p < t; p++) {
					b[j++] = a[p];
				}
				b[k++] = a[t];
				i = t;
				break;
			} else if (res == 0) {
				for (int p = i; p < t; p++) {
					b[k++] = a[p];
				}
				b[j++] = a[t];
				i = t;
				break;
			}
		}
	}
	for (int i = l; i <= r; i++) {
		a[i] = b[i];
	}
	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, rnd);
	solve(1, n);
	cout << 1 << ' ';
	for (int i = 1; i <= n; i++) {
		cout << a[i] << ' ';
	}
	cout << endl;

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2
2
2
2
0

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 59...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
2
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
2
0
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
2
1
0
1
2
0
2
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
0
2
0
2
2
2
0
2
2

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 441 44...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 201 20...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 232ms
memory: 3816kb

input:

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

output:

0 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 27...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 175 17...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 232ms
memory: 3820kb

input:

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

output:

0 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 780 78...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 248ms
memory: 3820kb

input:

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

output:

0 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 88...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 241 24...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 216ms
memory: 3732kb

input:

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

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

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

input:

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

output:

0 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 836 83...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 807 80...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 8...

result:

ok Accepted

Test #28:

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

input:

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

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

score: 0
Accepted
time: 222ms
memory: 3820kb

input:

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

output:

0 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 863 86...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 627 62...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 389 38...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 41...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 214ms
memory: 3740kb

input:

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

output:

0 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 519 51...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 488 48...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 237ms
memory: 3736kb

input:

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

output:

0 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 473 47...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 27...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 217ms
memory: 3736kb

input:

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

output:

0 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 988 98...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 727 72...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 228ms
memory: 3736kb

input:

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

output:

0 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 452 45...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 234ms
memory: 3736kb

input:

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

output:

0 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 81...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 240ms
memory: 3740kb

input:

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

output:

0 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 47...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed