結果
| 問題 | No.1194 Replace |
| コンテスト | |
| ユーザー |
37zigen
|
| 提出日時 | 2020-08-31 18:19:26 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,066 ms / 2,000 ms |
| + 751µs | |
| コード長 | 481 bytes |
| 記録 | |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 76,660 KB |
| 最終ジャッジ日時 | 2026-09-25 00:18:06 |
| 合計ジャッジ時間 | 25,554 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
import sys
sys.setrecursionlimit(10**6)
N,M=map(int,input().split())
g=dict()
e=[]
for i in range(M):
b,c=map(int,input().split())
e.append((c,b))
g[c]=[]
for a,b in e:
g[a].append(b)
e.sort(reverse=True)
to=dict()
ans=N*(N+1)//2
def dfs(cur,v):
global ans
for dst in g[cur]:
if dst in to or dst>v:
continue
to[dst]=v
ans+=v-dst
if dst in g:
dfs(dst,v)
for src,tmp in e:
dfs(src,src)
print(ans)
37zigen