結果
問題 | No.274 The Wall |
ユーザー | behoma8 |
提出日時 | 2023-03-07 16:11:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 572 ms / 2,000 ms |
コード長 | 1,714 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 81,784 KB |
実行使用メモリ | 213,476 KB |
最終ジャッジ日時 | 2023-10-18 05:31:39 |
合計ジャッジ時間 | 5,341 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
55,644 KB |
testcase_01 | AC | 44 ms
55,648 KB |
testcase_02 | AC | 43 ms
55,644 KB |
testcase_03 | AC | 256 ms
120,612 KB |
testcase_04 | AC | 44 ms
55,644 KB |
testcase_05 | AC | 44 ms
55,644 KB |
testcase_06 | AC | 44 ms
55,644 KB |
testcase_07 | AC | 44 ms
55,644 KB |
testcase_08 | AC | 43 ms
55,644 KB |
testcase_09 | AC | 44 ms
55,644 KB |
testcase_10 | AC | 43 ms
55,644 KB |
testcase_11 | AC | 572 ms
213,476 KB |
testcase_12 | AC | 133 ms
77,024 KB |
testcase_13 | AC | 60 ms
65,696 KB |
testcase_14 | AC | 109 ms
76,756 KB |
testcase_15 | AC | 149 ms
77,736 KB |
testcase_16 | AC | 303 ms
104,804 KB |
testcase_17 | AC | 309 ms
105,012 KB |
testcase_18 | AC | 318 ms
106,828 KB |
testcase_19 | AC | 185 ms
77,840 KB |
testcase_20 | AC | 200 ms
78,468 KB |
testcase_21 | AC | 200 ms
77,968 KB |
testcase_22 | AC | 212 ms
78,456 KB |
testcase_23 | AC | 204 ms
77,812 KB |
testcase_24 | AC | 211 ms
78,512 KB |
testcase_25 | AC | 203 ms
77,980 KB |
ソースコード
import math import sys import time from collections import defaultdict from collections import deque cur_time = time.perf_counter() INF = sys.maxsize sys.setrecursionlimit( 10 ** 8 ) def alg_graph_scc( gs, rgs, n ): """ gs: 隣接リスト rgs: 逆向き隣接リスト """ order = [] used = [0]*n group = [None]*n def dfs(s): used[s] = 1 for t in gs[s]: if not used[t]: dfs(t) order.append(s) def rdfs(s, col): group[s] = col used[s] = 1 for t in rgs[s]: if not used[t]: rdfs(t, col) for i in range(n): if not used[i]: dfs(i) used = [0]*n label = 0 for s in reversed(order): if not used[s]: rdfs(s, label) label += 1 return label, group N, M = [ int(i) for i in input().split() ] LR = [ [ int(i) for i in input().split() ] for _ in range( N ) ] def solve(): LRT = [] for l, r in LR: LRT.append( ( M - 1 - r, M - 1 - l ) ) gs = [[] for _ in range(2*N)] for i in range(N): l0, r0 = LR[i] for j in range(N): if i != j: l1, r1 = LRT[j] if not ( r0 < l1 or r1 < l0 ): # conflict gs[i].append( j ) gs[N+i].append( N+j ) l1, r1 = LR[j] if not( r0 < l1 or r1 < l0 ): # conflict gs[i].append( N+j ) gs[N+i].append( j ) label, group = alg_graph_scc( gs, gs, 2*N ) for i in range(N): if group[i] == group[i+N]: print( 'NO' ) return print( 'YES' ) solve()