QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742356#9432. PermutationSktn0089AC ✓276ms8228kbC++141.5kb2024-11-13 16:26:462024-11-13 16:26:46

Judging History

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

  • [2024-11-13 16:26:46]
  • 评测
  • 测评结果:AC
  • 用时:276ms
  • 内存:8228kb
  • [2024-11-13 16:26:46]
  • 提交

answer

#include <bits/stdc++.h>
#define ll int
#define fi first
#define se second
#define mkp make_pair
#define pir pair <ll, ll>
#define pb emplace_back
#define i128 __int128
using namespace std;
const ll maxn = 2e6 + 10, inf = 1e9;
ll n, a[maxn], b[maxn], d[maxn];
ll query() {
	printf("0");
	for(ll i = 1; i <= n; i++) printf(" %d", b[i]);
	puts(""), fflush(stdout);
	ll x; scanf("%d", &x); return x;
}
ll find(ll x) { return d[x] ^ x? d[x] = find(d[x]) : x; }
void solve(ll l, ll r, vector <ll> t) {
	if(l == r) { a[l] = t[0]; return; }
	ll mid = l + r >> 1;
	for(ll x: t) d[x] = x;
	vector <ll> L, R, ver = t;
	while(t.size() > 1) {
		ll x = t[t.size() - 1], y = t[t.size() - 2];
		t.pop_back(), t.pop_back();
		for(ll i = 1; i <= n; i++)
			b[i] = i <= mid? x : y;
		ll tmp = query();
		if(tmp == 1) {
			d[x] = y, t.pb(y);
		} else if(tmp == 0) {
			for(ll u: ver)
				if(find(u) == x) R.pb(u);
				else if(find(u) == y) L.pb(u);
		} else {
			for(ll u: ver)
				if(find(u) == x) L.pb(u);
				else if(find(u) == y) R.pb(u);
		}
	}
	if(!t.empty()) {
		for(ll u: ver)
			if(find(u) == t[0]) {
				if(L.size() < mid - l + 1) L.pb(u);
				else R.pb(u);
			}
	}
	solve(l, mid, L), solve(mid + 1, r, R);
}
int main() {
	scanf("%d", &n); srand(time(0));
	vector <ll> t(n);
	for(ll i = 0; i < n; i++) t[i] = i + 1;
	random_shuffle(t.begin(), t.end());
	solve(1, n, t);
	printf("1 ");
	for(ll i = 1; i <= n; i++) printf("%d ", a[i]);
	return 0;
}

詳細信息

Test #1:

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

input:

5
0
0
2
2
0

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 249ms
memory: 8224kb

input:

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

output:

0 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 857 85...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
2
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
1
0
0
2

output:

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

input:

6
1
0
0
1
2
0
1
2
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
1
2
2
2
2
0
0
0
0
0

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

0 1 1 1 1 1 1 8 8 8 8 8
0 7 7 7 7 7 7 11 11 11 11 11
0 10 10 10 10 10 10 9 9 9 9 9
0 9 9 9 9 9 9 5 5 5 5 5
0 5 5 5 5 5 5 2 2 2 2 2
0 6 6 6 6 6 6 3 3 3 3 3
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 5 5 5 7 7 7 7 7 7 7 7
0 7 7 3 3 3 3 3 3 3 3 3
0 3 3 10 10 10 10 10 10 10 10 10
0 7 3...

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 307 30...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 255ms
memory: 8000kb

input:

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

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

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

input:

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

output:

0 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 542 54...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 238ms
memory: 7888kb

input:

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

output:

0 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 4...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 239ms
memory: 7888kb

input:

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

output:

0 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 8...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 906 90...

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 257ms
memory: 8020kb

input:

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

output:

0 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 713 71...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 457 45...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 567 56...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 549 54...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 610 61...

result:

ok Accepted

Test #28:

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

input:

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

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

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

input:

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

score: 0
Accepted
time: 249ms
memory: 7928kb

input:

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

output:

0 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 609 60...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 848 84...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 10...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 729 72...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 274ms
memory: 7896kb

input:

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

output:

0 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 10...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 560 56...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 711 71...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 27 2...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 265ms
memory: 7956kb

input:

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

output:

0 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 260 26...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 247ms
memory: 7956kb

input:

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

output:

0 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 5...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 265ms
memory: 7952kb

input:

998
1
0
1
0
2
0
0
1
2
0
2
1
2
1
0
0
2
2
0
0
1
2
0
1
0
0
2
1
0
1
1
0
0
0
1
1
2
1
0
1
1
0
1
1
1
1
0
1
2
1
2
1
1
1
2
2
2
2
1
1
2
0
0
1
2
1
0
2
0
1
1
1
2
1
2
2
1
2
1
0
1
1
2
2
1
1
2
0
1
0
1
1
1
1
0
0
0
2
2
1
1
1
0
1
0
0
0
2
1
0
1
0
2
1
0
2
1
2
2
0
1
0
1
1
1
0
0
1
1
2
2
0
0
1
2
2
0
1
0
0
0
1
2
1
1
2
1
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: 276ms
memory: 7900kb

input:

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

output:

0 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 976 97...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed