結果
| 問題 | No.3103 Butterfly Effect |
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2025-01-13 03:16:13 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 825 bytes |
| 記録 | |
| コンパイル時間 | 1,770 ms |
| コンパイル使用メモリ | 85,148 KB |
| 実行使用メモリ | 65,792 KB |
| 最終ジャッジ日時 | 2026-06-12 12:31:34 |
| 合計ジャッジ時間 | 13,252 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 50 |
ソースコード
from sortedcontainers import SortedSet n, q = map(int,input().split()) x = [-1] * q y = [-1] * q dp = [q+1] * n dp[0] = -1 horyu = [SortedSet() for i in range(n)] ans = 1 for num in range(q): p, x, y = map(int,input().split()) p -= 1 x -= 1 y -= 1 if dp[x] < p and dp[y] < p: pass elif dp[x] > p and dp[y] > p: horyu[x].add((p,y)) horyu[x].add((p,x)) else: if dp[y] < p: x, y = y, x assert dp[x] < p and dp[y] > p if dp[y] == q+1: ans += 1 dp[y] = p mada = [(y, p)] while mada: i, t = mada.pop() while True: itr = horyu[y].bisect_left((t,0)) if itr == len(horyu[y]): break tim = horyu[y][itr][0] z = horyu[y][itr][1] horyu[y].discard(horyu[y][itr]) if dp[z] > tim: if dp[z] == q+1: ans += 1 dp[z] = tim mada.append((z, tim)) print(ans)
shobonvip