結果
問題 | No.1508 Avoid being hit |
ユーザー | tamato |
提出日時 | 2021-05-14 23:23:16 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,802 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 102,504 KB |
最終ジャッジ日時 | 2024-10-02 05:09:29 |
合計ジャッジ時間 | 8,794 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 36 ms
52,864 KB |
testcase_02 | AC | 37 ms
52,736 KB |
testcase_03 | AC | 36 ms
52,352 KB |
testcase_04 | AC | 36 ms
52,480 KB |
testcase_05 | AC | 37 ms
52,736 KB |
testcase_06 | RE | - |
testcase_07 | AC | 36 ms
53,120 KB |
testcase_08 | AC | 37 ms
52,480 KB |
testcase_09 | AC | 36 ms
52,864 KB |
testcase_10 | AC | 36 ms
52,352 KB |
testcase_11 | AC | 36 ms
52,480 KB |
testcase_12 | AC | 36 ms
52,864 KB |
testcase_13 | AC | 36 ms
52,608 KB |
testcase_14 | AC | 36 ms
52,736 KB |
testcase_15 | WA | - |
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 | 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 | 99 ms
93,952 KB |
testcase_35 | AC | 60 ms
73,984 KB |
testcase_36 | AC | 81 ms
84,864 KB |
testcase_37 | AC | 71 ms
78,100 KB |
testcase_38 | AC | 91 ms
89,276 KB |
testcase_39 | AC | 79 ms
84,496 KB |
testcase_40 | AC | 104 ms
96,128 KB |
testcase_41 | AC | 82 ms
86,016 KB |
testcase_42 | AC | 103 ms
96,128 KB |
testcase_43 | AC | 110 ms
99,584 KB |
testcase_44 | AC | 36 ms
52,736 KB |
testcase_45 | WA | - |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N, Q = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) ok = [1] * (N+2) ok[0] = ok[-1] = 0 st = set() for i in range(Q-1, -1, -1): a, b = A[i], B[i] st_new = set() for v in st: flg = ok[v-1] | ok[v] | ok[v+1] if flg: ok[v] = 1 if ok[v-1] == 0 and v-1 != 0: st_new.add(v-1) if ok[v+1] == 0 and v+1 != N+1: st_new.add(v+1) st = st_new st.add(a) st.add(b) ok[a] = ok[b] = 0 if sum(ok) == 0: print("NO") else: print("YES") ans = [] for v in range(1, N+1): if ok[v]: ans.append(v) break t = 0 F = [0] * Q back = 0 while t < Q: a, b = A[t], B[t] v = ans[-1] if back == 0: t += 1 if v != a and v != b: if v != 1 and v != N: ans.append(v) elif v == 1: if a != 2 and b != 2: ans.append(2) else: ans.append(1) elif v == N: if a != N-1 and b != N-1: ans.append(N-1) else: ans.append(N) else: if v == 1: if a != 2 and b != 2: ans.append(2) else: back = 1 elif v == N: if a != N-1 and b != N-1: ans.append(N-1) else: back = 1 else: if v-1 != a and v-1 != b and v+1 != a and v+1 != b: if F[t] == 0: ans.append(v-1) F[t] = 1 else: ans.append(v+1) F[t] = 0 elif v-1 != a and v-1 != b: ans.append(v-1) elif v+1 != a and v+1 != b: ans.append(v+1) else: back = 1 else: ans.pop() t -= 1 if F[t] == 1: back = 0 print(*ans, sep="\n") if __name__ == '__main__': main()