結果
問題 | No.274 The Wall |
ユーザー | behoma8 |
提出日時 | 2023-03-07 16:04:58 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,875 bytes |
コンパイル時間 | 828 ms |
コンパイル使用メモリ | 81,460 KB |
実行使用メモリ | 563,396 KB |
最終ジャッジ日時 | 2023-10-18 05:31:33 |
合計ジャッジ時間 | 8,423 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
55,468 KB |
testcase_01 | AC | 43 ms
55,472 KB |
testcase_02 | AC | 42 ms
55,468 KB |
testcase_03 | AC | 690 ms
306,796 KB |
testcase_04 | AC | 44 ms
55,596 KB |
testcase_05 | AC | 43 ms
55,596 KB |
testcase_06 | AC | 42 ms
55,596 KB |
testcase_07 | AC | 42 ms
55,596 KB |
testcase_08 | AC | 43 ms
55,596 KB |
testcase_09 | AC | 43 ms
55,596 KB |
testcase_10 | AC | 42 ms
55,596 KB |
testcase_11 | TLE | - |
testcase_12 | AC | 251 ms
76,872 KB |
testcase_13 | AC | 59 ms
65,592 KB |
testcase_14 | AC | 118 ms
76,724 KB |
testcase_15 | AC | 160 ms
77,756 KB |
testcase_16 | AC | 658 ms
296,092 KB |
testcase_17 | AC | 629 ms
283,888 KB |
testcase_18 | AC | 665 ms
306,400 KB |
testcase_19 | AC | 194 ms
78,184 KB |
testcase_20 | AC | 199 ms
78,300 KB |
testcase_21 | AC | 207 ms
78,332 KB |
testcase_22 | AC | 215 ms
78,280 KB |
testcase_23 | AC | 213 ms
78,356 KB |
testcase_24 | AC | 212 ms
78,348 KB |
testcase_25 | AC | 208 ms
78,424 KB |
ソースコード
import math import sys from collections import defaultdict from collections import deque 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[j].append( i ) gs[N+i].append( N+j ) gs[N+j].append( N+i ) l1, r1 = LR[j] if not( r0 < l1 or r1 < l0 ): # conflict gs[i].append( N+j ) gs[j].append( N+i ) gs[N+i].append( j ) gs[N+j].append( i ) # print( gs ) label, group = alg_graph_scc( gs, gs, 2*N ) # print( label, group ) for i in range(N): if group[i] == group[i+N]: print( 'NO' ) return print( 'YES' ) solve()