結果

問題 No.274 The Wall
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-11 23:32:40
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 1,183 bytes
コンパイル時間 53 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-04-15 15:14:45
合計ジャッジ時間 18,909 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,272 KB
testcase_01 AC 13 ms
6,528 KB
testcase_02 AC 16 ms
6,272 KB
testcase_03 AC 17 ms
6,528 KB
testcase_04 AC 12 ms
6,272 KB
testcase_05 AC 12 ms
6,272 KB
testcase_06 AC 12 ms
6,272 KB
testcase_07 AC 12 ms
6,272 KB
testcase_08 AC 12 ms
6,400 KB
testcase_09 AC 12 ms
6,272 KB
testcase_10 AC 16 ms
6,272 KB
testcase_11 AC 22 ms
7,168 KB
testcase_12 AC 1,488 ms
7,040 KB
testcase_13 AC 113 ms
6,400 KB
testcase_14 AC 730 ms
6,528 KB
testcase_15 AC 1,491 ms
6,784 KB
testcase_16 AC 20 ms
7,040 KB
testcase_17 AC 19 ms
6,912 KB
testcase_18 AC 19 ms
7,040 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 AC 117 ms
7,040 KB
testcase_23 AC 502 ms
7,040 KB
testcase_24 TLE -
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

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