結果
問題 | No.274 The Wall |
ユーザー |
![]() |
提出日時 | 2016-05-11 23:33:00 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 295 ms / 2,000 ms |
コード長 | 1,183 bytes |
コンパイル時間 | 1,768 ms |
コンパイル使用メモリ | 76,860 KB |
実行使用メモリ | 79,884 KB |
最終ジャッジ日時 | 2024-06-22 02:09:11 |
合計ジャッジ時間 | 6,286 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
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"