結果

問題 No.1508 Avoid being hit
ユーザー trineutrontrineutron
提出日時 2021-05-14 23:46:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,573 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 60,956 KB
最終ジャッジ日時 2024-04-10 04:34:46
合計ジャッジ時間 20,627 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 704 ms
48,916 KB
testcase_01 AC 30 ms
11,136 KB
testcase_02 AC 30 ms
11,008 KB
testcase_03 AC 30 ms
11,136 KB
testcase_04 AC 29 ms
11,008 KB
testcase_05 AC 29 ms
11,008 KB
testcase_06 RE -
testcase_07 AC 29 ms
11,008 KB
testcase_08 AC 30 ms
11,008 KB
testcase_09 AC 30 ms
11,136 KB
testcase_10 AC 30 ms
11,008 KB
testcase_11 AC 30 ms
11,008 KB
testcase_12 AC 30 ms
11,008 KB
testcase_13 AC 30 ms
11,008 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 681 ms
49,728 KB
testcase_35 AC 91 ms
14,976 KB
testcase_36 AC 380 ms
33,012 KB
testcase_37 AC 178 ms
20,716 KB
testcase_38 AC 554 ms
42,176 KB
testcase_39 AC 345 ms
31,152 KB
testcase_40 AC 699 ms
51,560 KB
testcase_41 AC 402 ms
34,196 KB
testcase_42 AC 740 ms
51,888 KB
testcase_43 AC 855 ms
58,828 KB
testcase_44 RE -
testcase_45 RE -
権限があれば一括ダウンロードができます

ソースコード

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 seg in segs[i + 1]:
        l, r = seg
        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]:
                if a[i] + 1 == segs[i][j + 1][0]:
                    print('NO')
                    exit()
                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])
        if a[i] == b[i]:
            continue
        if segs[i][j][1] <= b[i] < segs[i][j + 1][0]:
            if segs[i][j][1] == b[i]:
                if b[i] + 1 == segs[i][j + 1][0]:
                    print('NO')
                    exit()
                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()

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