結果

問題 No.274 The Wall
ユーザー rlangevinrlangevin
提出日時 2024-02-04 11:49:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 76,836 KB
最終ジャッジ日時 2024-02-04 11:49:47
合計ジャッジ時間 4,041 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
56,788 KB
testcase_02 AC 43 ms
58,992 KB
testcase_03 AC 63 ms
68,696 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 43 ms
58,992 KB
testcase_10 AC 44 ms
58,992 KB
testcase_11 AC 62 ms
68,680 KB
testcase_12 AC 153 ms
76,836 KB
testcase_13 AC 53 ms
61,188 KB
testcase_14 AC 92 ms
67,860 KB
testcase_15 AC 144 ms
76,580 KB
testcase_16 AC 67 ms
70,768 KB
testcase_17 AC 68 ms
70,768 KB
testcase_18 AC 67 ms
70,780 KB
testcase_19 AC 137 ms
76,584 KB
testcase_20 AC 178 ms
76,580 KB
testcase_21 AC 181 ms
76,580 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 188 ms
76,580 KB
testcase_25 AC 191 ms
76,580 KB
権限があれば一括ダウンロードができます

ソースコード

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