結果

問題 No.274 The Wall
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-11 23:33:00
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 308 ms / 2,000 ms
コード長 1,183 bytes
コンパイル時間 1,154 ms
コンパイル使用メモリ 77,412 KB
実行使用メモリ 81,252 KB
最終ジャッジ日時 2023-09-04 02:11:08
合計ジャッジ時間 6,085 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
76,136 KB
testcase_01 AC 90 ms
78,732 KB
testcase_02 AC 86 ms
79,272 KB
testcase_03 AC 101 ms
79,580 KB
testcase_04 AC 76 ms
76,272 KB
testcase_05 AC 75 ms
76,676 KB
testcase_06 AC 76 ms
76,292 KB
testcase_07 AC 76 ms
76,260 KB
testcase_08 AC 76 ms
76,404 KB
testcase_09 AC 74 ms
76,412 KB
testcase_10 AC 86 ms
79,048 KB
testcase_11 AC 108 ms
79,804 KB
testcase_12 AC 164 ms
80,340 KB
testcase_13 AC 113 ms
79,940 KB
testcase_14 AC 169 ms
80,344 KB
testcase_15 AC 224 ms
80,456 KB
testcase_16 AC 103 ms
79,808 KB
testcase_17 AC 104 ms
79,512 KB
testcase_18 AC 103 ms
79,912 KB
testcase_19 AC 263 ms
80,624 KB
testcase_20 AC 279 ms
80,756 KB
testcase_21 AC 285 ms
80,780 KB
testcase_22 AC 139 ms
80,712 KB
testcase_23 AC 156 ms
80,648 KB
testcase_24 AC 308 ms
81,252 KB
testcase_25 AC 290 ms
80,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,raw_input().split())
lines=[]
blocked=[False for i in range(M)]
used=[False for i in range(N)]
for i in range(N):
    L,R=map(int,raw_input().split())
    lines.append(((L,R),(M-R-1,M-L-1)))

useCnt=0
while useCnt < N:
    toCheck=[]
    for i in range(N):
        if used[i]==False:
            toCheck.append((i,0))
            used[i]=True
            break
    while len(toCheck)!=0:
        p,q=toCheck[0]
        toCheck.pop(0)
        l,r=lines[p][q]
        useCnt+=1
        for c in range(l,r+1):
            if blocked[c]==True:
                print "NO"
                exit()
            blocked[c]=True
            for t in range(N):
                if used[t]==False:
                    if lines[t][0][0]<=c and lines[t][0][1]>=c and lines[t][1][0]<=c and lines[t][1][1]>=c:
                        print "NO"
                        exit()
                    elif lines[t][0][0]<=c and lines[t][0][1]>=c :
                        toCheck.append((t,1))
                        used[t]=True
                    elif lines[t][1][0]<=c and lines[t][1][1]>=c :
                        toCheck.append((t,0))
                        used[t]=True
print "YES"

0