結果
問題 | No.274 The Wall |
ユーザー |
![]() |
提出日時 | 2016-05-11 23:32:40 |
言語 | Python2 (2.7.18) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,183 bytes |
コンパイル時間 | 58 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 7,040 KB |
最終ジャッジ日時 | 2024-10-05 13:51:02 |
合計ジャッジ時間 | 16,555 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 TLE * 4 |
ソースコード
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=0while useCnt < N:toCheck=[]for i in range(N):if used[i]==False:toCheck.append((i,0))used[i]=Truebreakwhile len(toCheck)!=0:p,q=toCheck[0]toCheck.pop(0)l,r=lines[p][q]useCnt+=1for c in range(l,r+1):if blocked[c]==True:print "NO"exit()blocked[c]=Truefor 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]=Trueelif lines[t][1][0]<=c and lines[t][1][1]>=c :toCheck.append((t,0))used[t]=Trueprint "YES"