結果

問題 No.1508 Avoid being hit
ユーザー trineutrontrineutron
提出日時 2021-05-15 00:31:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,835 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 59,900 KB
最終ジャッジ日時 2024-04-10 05:47:13
合計ジャッジ時間 22,218 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 774 ms
47,172 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 AC 27 ms
11,008 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 28 ms
10,880 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 29 ms
11,008 KB
testcase_08 AC 28 ms
10,880 KB
testcase_09 AC 29 ms
11,008 KB
testcase_10 AC 29 ms
11,008 KB
testcase_11 AC 28 ms
10,880 KB
testcase_12 AC 28 ms
11,008 KB
testcase_13 AC 29 ms
11,008 KB
testcase_14 WA -
testcase_15 AC 28 ms
11,008 KB
testcase_16 AC 636 ms
43,984 KB
testcase_17 AC 354 ms
29,588 KB
testcase_18 AC 332 ms
27,648 KB
testcase_19 AC 513 ms
38,404 KB
testcase_20 AC 815 ms
54,180 KB
testcase_21 AC 544 ms
39,188 KB
testcase_22 AC 674 ms
46,216 KB
testcase_23 AC 736 ms
50,392 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 882 ms
50,264 KB
testcase_35 AC 110 ms
15,232 KB
testcase_36 AC 520 ms
33,160 KB
testcase_37 AC 224 ms
20,736 KB
testcase_38 AC 723 ms
42,696 KB
testcase_39 AC 448 ms
31,428 KB
testcase_40 AC 922 ms
52,452 KB
testcase_41 AC 535 ms
34,388 KB
testcase_42 AC 938 ms
52,672 KB
testcase_43 AC 1,100 ms
59,900 KB
testcase_44 WA -
testcase_45 AC 28 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, q = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

segs = [None] * (q + 1)
segs[q] = [[0, 1], [n + 1, n + 2]]
for i in reversed(range(q)):
    segs[i] = []
    for j in range(len(segs[i + 1])):
        l, r = segs[i + 1][j]
        if j != 0 and segs[i + 1][j - 1][1] == l:
            continue
        jcopy = j
        while jcopy != len(segs[i + 1]) - 1 and r == segs[i + 1][jcopy + 1][0]:
            jcopy += 1
            r = segs[i + 1][jcopy][1]
        if 0 < l < n + 1:
            l += 1
        if 1 < r < n + 2:
            r -= 1
        if l < r:
            segs[i].append([l, r])
    for j in range(len(segs[i]) - 1):
        if segs[i][j][1] <= a[i] < segs[i][j + 1][0]:
            if segs[i][j][1] == a[i]:
                segs[i][j][1] += 1
            elif a[i] + 1 == segs[i][j + 1][0]:
                segs[i][j + 1][0] -= 1
            else:
                segs[i].append([a[i], a[i] + 1])
    segs[i].sort()
    if a[i] == b[i]:
        continue
    for j in range(len(segs[i]) - 1):
        if segs[i][j][1] <= b[i] < segs[i][j + 1][0]:
            if segs[i][j][1] == b[i]:
                segs[i][j][1] += 1
            elif b[i] + 1 == segs[i][j + 1][0]:
                segs[i][j + 1][0] -= 1
            else:
                segs[i].append([b[i], b[i] + 1])
    segs[i].sort()

ans = []
for i in range(len(segs[0]) - 1):
    if segs[0][i][1] != segs[0][i + 1][0]:
        s = segs[0][i][1]
        break
else:
    print('NO')
    exit()
ans.append(s)
for i in range(q):
    for j in range(len(segs[i]) - 1):
        if abs(segs[i][j][1] - s) <= 1 and segs[i][j][1] != segs[i][j + 1][0]:
            s = segs[i][j][1]
            ans.append(s)
            break
    else:
        print('NO')
        exit()
print('YES')
for x in ans:
    print(x)
0