結果

問題 No.274 The Wall
ユーザー rlangevin
提出日時 2024-02-04 11:49:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 82,072 KB
実行使用メモリ 77,092 KB
最終ジャッジ日時 2024-09-28 11:13:57
合計ジャッジ時間 4,343 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(L1, R1, L2, R2):
    for i in range(M):
        if L1 <= i <= R1 and L2 <= i <= R2:
            return False
    return True

N, M = map(int, input().split())
pre0, pre1 = 1, 1
preL, preR = map(int, input().split())
for i in range(N - 1):
    L, R = map(int, input().split())
    dp0, dp1 = 0, 0
    if pre0:
        if check(L, R, preL, preR):
            dp0 = 1
        if check(M + 1 - R, M + 1 - L, preL, preR):
            dp1 = 1
            
    if pre1:
        if check(L, R, M + 1 - preR, M + 1 - preL):
            dp0 = 1
        if check(M + 1 - R, M + 1 - L, M + 1 - preR, M + 1 - preL):
            dp1 = 1
    pre0, pre1 = dp0, dp1
    preL, preR = L, R
    
print("YES") if pre0 or pre1 else print("NO")
0