結果
問題 | No.1983 [Cherry 4th Tune C] 南の島のマーメイド |
ユーザー | neginagi |
提出日時 | 2022-08-28 13:34:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,579 bytes |
コンパイル時間 | 669 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 305,792 KB |
最終ジャッジ日時 | 2024-10-15 12:23:08 |
合計ジャッジ時間 | 27,067 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 132 ms
86,272 KB |
testcase_01 | AC | 130 ms
86,148 KB |
testcase_02 | AC | 130 ms
86,400 KB |
testcase_03 | AC | 129 ms
85,888 KB |
testcase_04 | WA | - |
testcase_05 | AC | 129 ms
86,272 KB |
testcase_06 | AC | 129 ms
86,516 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 129 ms
86,272 KB |
testcase_34 | AC | 264 ms
107,520 KB |
testcase_35 | AC | 729 ms
291,200 KB |
testcase_36 | AC | 359 ms
121,856 KB |
testcase_37 | AC | 132 ms
86,272 KB |
testcase_38 | AC | 201 ms
89,728 KB |
testcase_39 | AC | 753 ms
305,792 KB |
testcase_40 | AC | 384 ms
143,908 KB |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) INF = float("INF") MOD = 10 ** 9 + 7 MOD2 = 998244353 from heapq import heappop, heappush import math from collections import Counter, deque from itertools import accumulate, combinations, combinations_with_replacement, permutations from bisect import bisect_left, bisect_right import decimal n, m, q = map(int, input().split()) edge = [[] for _ in range(n)] for i in range(m): u, v = map(int, input().split()) u, v = u - 1, v - 1 edge[u].append(v) edge[v].append(u) ord = [-1] * n low = [-1] * n cnt = 0 def dfs(i, p): global cnt ord[i] = cnt cnt += 1 low[i] = ord[i] for to in edge[i]: if to == p: continue if ord[to] != -1: low[i] = min(low[i], ord[to]) continue dfs(to, i) low[i] = min(low[i], low[to]) dfs(0, -1) def is_bridge(i, j): if ord[i] < low[j]: return True return False edge2 = [[] for _ in range(n)] for i in range(n): for j in edge[i]: if is_bridge(i, j): edge2[i].append(j) seen = [-1] * n for i in range(n): if seen[i] != -1: continue seen[i] = i que = deque() que.append(i) while que: x = que.popleft() for to in edge2[x]: if seen[to] != -1: continue seen[to] = seen[x] que.append(to) for i in range(q): x, y = map(int, input().split()) x, y = x - 1, y - 1 if seen[x] != seen[y]: print("No") else: print("Yes")