QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#595839#9432. Permutationucup-team112#AC ✓512ms13696kbPython32.1kb2024-09-28 14:34:202024-09-28 14:34:22

Judging History

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

  • [2024-09-28 14:34:22]
  • 评测
  • 测评结果:AC
  • 用时:512ms
  • 内存:13696kb
  • [2024-09-28 14:34:20]
  • 提交

answer

from pprint import pprint
import random

DEBUG = False

if DEBUG:
    # random.seed(0)
    x = ""
    n = 1000
    A = [i for i in range(1, n + 1)]
    qc = 0
    random.shuffle(A)

    def print(Q, flush):
        # pprint(Q)

        B = list(map(int, Q.split()[1:]))

        global x, qc
        qc += 1
        if Q[0] == "1":
            pprint(f"{qc=}")
            assert qc <= 6666
            assert A == B
            exit(0)
        cnt = 0
        for a, b in zip(A, B):
            if a == b:
                cnt += 1
        x = str(cnt)

    def input():
        return x


def judge(Q):
    print(Q, flush=True)
    if Q[0] == "1":
        exit()
    return int(input())


if not DEBUG:
    n = int(input())


C = [i for i in range(1, n + 1)]
ans = [0] * n


def dfs(l, r, C):
    random.shuffle(C)
    assert r - l == len(C)
    if r - l == 1:
        ans[l] = C[0]
        return

    mid = (l + r) // 2
    L = []
    R = []
    now = [[c] for c in C]
    while now:
        nex = []
        while len(now) >= 2:
            aa = now.pop()
            a = aa[0]
            bb = now.pop()
            b = bb[0]
            Q = [a] * n
            for i in range(mid, r):
                Q[i] = b

            S = f"0 {' '.join(map(str, Q))}"
            res = judge(S)
            if res == 0:
                L.extend(bb)
                R.extend(aa)
            elif res == 1:
                aa.extend(bb)
                nex.append(aa)
            else:
                L.extend(aa)
                R.extend(bb)
        if now:
            nex.append(now.pop())
        now = nex
        # pprint(f"{len(L)=} {len(R)=} {len(now)=} {l=} {r=} {mid=}")
        if mid - l == len(L):
            for row in now:
                R.extend(row)
            break
        if r - mid == len(R):
            for row in now:
                L.extend(row)
            break

    # pprint(f"{len(L)=} {len(R)=} {l=} {r=} {mid=}")
    dfs(l, mid, L)
    dfs(mid, r, R)


dfs(0, n, C)
judge(f"1 {' '.join(map(str, ans))}")

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 30ms
memory: 13036kb

input:

5
1
2
2
0
0
0

output:

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

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 488ms
memory: 13520kb

input:

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

output:

0 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 565 56...

result:

ok Accepted

Test #3:

score: 0
Accepted
time: 22ms
memory: 12968kb

input:

1

output:

1 1

result:

ok Accepted

Test #4:

score: 0
Accepted
time: 15ms
memory: 13024kb

input:

2
0

output:

0 1 2
1 2 1

result:

ok Accepted

Test #5:

score: 0
Accepted
time: 23ms
memory: 13044kb

input:

3
0
2

output:

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

result:

ok Accepted

Test #6:

score: 0
Accepted
time: 16ms
memory: 13036kb

input:

4
2
2
2
0

output:

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

result:

ok Accepted

Test #7:

score: 0
Accepted
time: 29ms
memory: 13100kb

input:

6
1
1
0
0
1
2
0
1
2
2

output:

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

result:

ok Accepted

Test #8:

score: 0
Accepted
time: 11ms
memory: 13152kb

input:

7
2
0
2
1
2
2
0
2
0
0

output:

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

result:

ok Accepted

Test #9:

score: 0
Accepted
time: 26ms
memory: 13056kb

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

score: 0
Accepted
time: 17ms
memory: 13052kb

input:

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

output:

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

result:

ok Accepted

Test #12:

score: 0
Accepted
time: 30ms
memory: 13044kb

input:

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

output:

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

result:

ok Accepted

Test #13:

score: 0
Accepted
time: 21ms
memory: 13108kb

input:

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

output:

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

result:

ok Accepted

Test #14:

score: 0
Accepted
time: 27ms
memory: 13152kb

input:

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

output:

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

result:

ok Accepted

Test #15:

score: 0
Accepted
time: 27ms
memory: 13216kb

input:

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

output:

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

result:

ok Accepted

Test #16:

score: 0
Accepted
time: 30ms
memory: 13136kb

input:

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

output:

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

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 489ms
memory: 13672kb

input:

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

output:

0 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 152 15...

result:

ok Accepted

Test #18:

score: 0
Accepted
time: 477ms
memory: 13668kb

input:

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

output:

0 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 13...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 481ms
memory: 13592kb

input:

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

output:

0 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 381 38...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 482ms
memory: 13608kb

input:

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

output:

0 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 400 40...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 487ms
memory: 13576kb

input:

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

output:

0 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 225 22...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 502ms
memory: 13496kb

input:

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

output:

0 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 426 42...

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 484ms
memory: 13504kb

input:

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

output:

0 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 292 29...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 486ms
memory: 13620kb

input:

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

output:

0 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 912 91...

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 478ms
memory: 13684kb

input:

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

output:

0 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 15...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 497ms
memory: 13528kb

input:

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

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

score: 0
Accepted
time: 510ms
memory: 13484kb

input:

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

output:

0 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 982 98...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 474ms
memory: 13500kb

input:

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

output:

0 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 736 73...

result:

ok Accepted

Test #29:

score: 0
Accepted
time: 485ms
memory: 13512kb

input:

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

output:

0 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 182 18...

result:

ok Accepted

Test #30:

score: 0
Accepted
time: 512ms
memory: 13592kb

input:

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

output:

0 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 14...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 479ms
memory: 13696kb

input:

989
0
1
1
2
1
2
2
1
2
1
1
1
1
2
1
1
1
0
2
1
2
2
1
1
1
2
1
1
0
1
2
1
2
1
0
1
0
0
0
1
2
1
1
2
0
2
1
0
0
2
0
0
1
1
0
0
1
1
1
1
2
1
2
2
2
1
1
1
0
0
2
1
1
1
1
0
2
0
1
0
1
0
1
0
1
2
0
1
1
1
1
1
1
0
1
2
0
1
1
2
1
0
1
0
1
0
1
2
1
2
0
2
1
2
2
1
0
1
0
1
2
0
1
2
2
2
1
1
1
0
0
0
0
2
0
2
2
0
2
2
0
0
1
0
2
2
2
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: 467ms
memory: 13696kb

input:

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

output:

0 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 1...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 511ms
memory: 13532kb

input:

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

output:

0 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 2...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 480ms
memory: 13588kb

input:

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

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

Test #35:

score: 0
Accepted
time: 501ms
memory: 13580kb

input:

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

output:

0 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 629 62...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 449ms
memory: 13596kb

input:

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

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: 505ms
memory: 13696kb

input:

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

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

score: 0
Accepted
time: 511ms
memory: 13680kb

input:

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

output:

0 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 94 9...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 494ms
memory: 13484kb

input:

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

output:

0 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 751 75...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 503ms
memory: 13552kb

input:

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

output:

0 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 89...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 473ms
memory: 13504kb

input:

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

output:

0 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 8...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed