結果
| 問題 |
No.274 The Wall
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2023-05-17 10:09:48 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,819 bytes |
| コンパイル時間 | 105 ms |
| コンパイル使用メモリ | 13,056 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-12-15 05:33:05 |
| 合計ジャッジ時間 | 1,964 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 WA * 1 |
ソースコード
import sys
readline=sys.stdin.readline
def SCC(N,edges):
start = [0] * (N + 1)
elist = [0] * len(edges)
for e in edges:
start[e[0] + 1] += 1
for i in range(1, N + 1):
start[i] += start[i - 1]
counter = start[:]
for e in edges:
elist[counter[e[0]]] = e[1]
counter[e[0]] += 1
N = N
now_ord = group_num = 0
visited = []
low = [0] * N
order = [-1] * N
ids = [0] * N
parent = [-1] * N
stack = []
for i in range(N):
if order[i] == -1:
stack.append(i)
stack.append(i)
while stack:
v = stack.pop()
if order[v] == -1:
low[v] = order[v] = now_ord
now_ord += 1
visited.append(v)
for i in range(start[v], start[v + 1]):
to = elist[i]
if order[to] == -1:
stack.append(to)
stack.append(to)
parent[to] = v
else:
low[v] = min(low[v], order[to])
else:
if low[v] == order[v]:
while True:
u = visited.pop()
order[u] = N
ids[u] = group_num
if u == v:
break
group_num += 1
if parent[v] != -1:
low[parent[v]] = min(low[parent[v]], low[v])
for i, x in enumerate(ids):
ids[i] = group_num - 1 - x
groups = [[] for _ in range(group_num)]
for i, x in enumerate(ids):
groups[x].append(i)
return groups
class TwoSAT:
def __init__(self,N):
self.N=N
self.edges=[]
def Add_Clause(self,i,f,j,g):
assert 0<=i<self.N
assert 0<=j<self.N
self.edges.append((2*i+(0 if f else 1),2*j+(1 if g else 0)))
self.edges.append((2*j+(0 if g else 1),2*i+(1 if f else 0)))
def Satisfiable(self):
scc=SCC(2*self.N,self.edges)
idx=[None]*2*self.N
for i,lst in enumerate(scc):
for x in lst:
idx[x]=i
retu=[None]*self.N
for i in range(self.N):
if idx[2*i]==idx[2*i+1]:
return None
retu[i]=idx[2*i]<idx[2*i+1]
return retu
N,M=map(int,readline().split())
LR=[]
for n in range(N):
l,r=map(int,readline().split())
r+=1
l,r=min((l,r),(M-r,M-l))
LR.append((l,r))
used=[False]*M
for l,r in sorted(LR):
if used[l]:
l,r=M-r,M-l
if used[l]:
print("NO")
exit()
for i in range(l,r):
used[i]=True
print("YES")
vwxyz