QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741729#9432. PermutationYansuan_HClAC ✓281ms3928kbC++143.2kb2024-11-13 15:06:022024-11-13 15:06:02

Judging History

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

  • [2024-11-13 15:06:02]
  • 评测
  • 测评结果:AC
  • 用时:281ms
  • 内存:3928kb
  • [2024-11-13 15:06:02]
  • 提交

answer

#include <bits/stdc++.h>
#define ms(x, v) memset(x, v, sizeof(x))
#define il __attribute__((always_inline)) static
#define U(i,l,r) for(int i(l),END##i(r);i<=END##i;++i)
#define D(i,r,l) for(int i(r),END##i(l);i>=END##i;--i)
using namespace std;
using ll = long long;

#define IC isdigit(c)
#define GC c=getchar()
void rd(auto &x) { x = 0; char GC; bool f = 0;
	for (; !IC; GC) f |= c == '-';
	for (; IC; GC) x = x * 10 + c - 48;
	if (f) x = -x;
}
void rd(auto &x, auto &...y) { rd(x); rd(y...); }
#define meow(...) fprintf(stderr, __VA_ARGS__)
#define Assert(e, v) if (!(e)) { meow("AF@%d\n", __LINE__ ); exit(v); }

#define vc vector
#define eb emplace_back
#define pb push_back

const int N = 1003;
int n, a[N], p[N];
int q[N];
int ans[N], ansp[N];

int ask() {
	printf("0");
	U (i, 1, n) printf(" %d", q[i]);
	puts(""); fflush(stdout);
	int x; rd(x);
	return x;
}
//int ask() {
//	int cnt = 0;
//	U (i, 1, n) if (q[i] == ans[i]) ++cnt;
//	return cnt;
//}

void report() {
	printf("1");
	U (i, 1, n) printf(" %d", p[i]);
	puts(""); fflush(stdout);
	
//	U (i, 1, n) assert(p[i] == ans[i]);
	exit(0);
}

mt19937 rng(114514);

int b[N];
void solve(int l, int r) {
	if (l == r) { p[l] = a[l]; return; }
	shuffle(a + l, a + r + 1, rng);
	U (i, 1, n) q[i] = a[l];
	int mid((l + r) >> 1), x = l, y = mid + 1;
	for (int i = l, j; i <= r; i = j + 1) {
		j = i + 1; int las = 1;
		do {
			if (j > r) break;
			U (k, l, mid) q[k] = a[i];
			U (k, mid + 1, r) q[k] = a[j];
			las = ask();
		} while ((las == 1) && ++j);
		if (j > r) {
			// 要么 i 在左边,剩下的全在右边
			// 要么 i 在右边,剩下的全在左边
			if (i == r - 1) {
				assert(i != l); // 要么两个都对,要么两个都不对
				if (x + 1 == mid) {
					b[x++] = a[i];
					b[x++] = a[i + 1];
				} else if (y + 1 == r) {
					b[y++] = a[i];
					b[y++] = a[i + 1];
				} else {
					if (x != l) {
						U (k, l, mid) q[k] = b[l];
						U (k, mid + 1, r) q[k] = a[i];
						las = ask();
						if (las == 1) {
							b[x++] = a[i];
							b[y++] = a[i + 1];
						} else {
							assert(las == 2);
							b[y++] = a[i];
							b[x++] = a[i + 1];
						}
					} else {
						assert(y > mid + 1);
						U (k, l, mid) q[k] = a[i];
						U (k, mid + 1, r) q[k] = b[mid + 1];
						las = ask();
						if (las == 1) {
							b[y++] = a[i];
							b[x++] = a[i + 1];
						} else {
							assert(las == 2);
							b[y++] = a[i + 1];
							b[x++] = a[i];
						}
					}
				}
			} else {
				if (y == r + 1) {
					U (k, i, j - 1) b[x++] = a[k];
				} else {
					U (k, i, j - 1) b[y++] = a[k];
				}
			}
		} else if (las == 0) {
			// i 在右边
			b[y++] = a[i];
			b[x++] = a[j];
			U (k, i + 1, j - 1) b[y++] = a[k];
		} else if (las == 2) {
			// i 在左边
			b[x++] = a[i];
			b[y++] = a[j];
			U (k, i + 1, j - 1) b[x++] = a[k];
		}
	}
	assert(x == mid + 1);
	assert(y == r + 1);
	
	U (i, l, r) a[i] = b[i];
//	U (i, l, mid) assert(ansp[a[i]] <= mid);
//	U (i, mid + 1, r) assert(ansp[a[i]] > mid);
	 
	solve(l, mid);
	solve(mid + 1, r);
}

int main() {
//	freopen("ava.in", "r", stdin);
	rd(n);
	
//	U (i, 1, n) rd(ans[i]), ansp[ans[i]] = i;
	
	U (i, 1, n) a[i] = i;
	solve(1, n);
	report();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1
0
1
0
2
0

output:

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

input:

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

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

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
1
2
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
0
2
0
0

output:

0 1 1 4 4
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: 0ms
memory: 3772kb

input:

6
0
1
0
2
2
2
0

output:

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

input:

7
2
2
0
2
0
2
0
2
0

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #18:

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

input:

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

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: 235ms
memory: 3804kb

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #20:

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

input:

978
0
0
0
2
1
1
1
1
1
1
0
2
0
1
1
0
2
2
0
2
1
0
0
1
2
0
2
2
2
1
2
1
0
0
1
2
0
0
1
1
1
0
2
0
1
2
1
0
1
2
1
1
0
2
1
1
2
1
1
1
1
2
1
0
0
1
1
2
0
1
1
0
1
1
1
1
0
2
1
0
2
2
2
0
0
0
1
1
0
2
0
1
1
2
2
0
1
2
2
1
1
2
2
1
2
1
1
2
2
1
1
0
1
1
1
0
0
1
2
1
0
1
1
0
1
2
1
1
1
2
1
1
1
2
0
1
1
1
2
1
2
2
1
0
2
2
0
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 #21:

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #22:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #24:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #26:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #28:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #30:

score: 0
Accepted
time: 254ms
memory: 3748kb

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #32:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #34:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #36:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #38:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #40:

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

input:

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

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

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

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed