結果
問題 | No.2464 To DAG |
ユーザー | mkawa2 |
提出日時 | 2023-09-08 22:27:46 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,444 bytes |
コンパイル時間 | 489 ms |
コンパイル使用メモリ | 11,144 KB |
実行使用メモリ | 182,316 KB |
最終ジャッジ日時 | 2023-09-08 22:28:24 |
合計ジャッジ時間 | 31,596 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
8,212 KB |
testcase_01 | AC | 17 ms
8,012 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 1,803 ms
120,004 KB |
testcase_04 | AC | 1,825 ms
118,332 KB |
testcase_05 | AC | 1,832 ms
117,876 KB |
testcase_06 | AC | 1,886 ms
117,640 KB |
testcase_07 | AC | 1,184 ms
83,224 KB |
testcase_08 | AC | 1,540 ms
98,356 KB |
testcase_09 | AC | 1,453 ms
93,920 KB |
testcase_10 | AC | 1,542 ms
96,236 KB |
testcase_11 | AC | 1,032 ms
70,300 KB |
testcase_12 | AC | 813 ms
58,284 KB |
testcase_13 | AC | 1,142 ms
73,496 KB |
testcase_14 | AC | 1,131 ms
82,196 KB |
testcase_15 | AC | 1,433 ms
103,052 KB |
testcase_16 | AC | 789 ms
61,176 KB |
testcase_17 | AC | 115 ms
16,280 KB |
testcase_18 | AC | 469 ms
39,520 KB |
testcase_19 | AC | 17 ms
8,156 KB |
testcase_20 | AC | 17 ms
8,092 KB |
testcase_21 | AC | 17 ms
8,132 KB |
testcase_22 | TLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
ソースコード
import sys sys.setrecursionlimit(300005) # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(1000005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = -1-(-1 << 63) # md = 10**9+7 md = 998244353 def dfs(u): vis[u]=1 for v,i in to[u]: if seen[i]:continue seen[i]=1 if vis[v]==2:continue if vis[v]==1: vis[u]=0 dead[i]=1 return v r=dfs(v) if r==u: dead[i]=1 elif r!=-1: dead[i]=1 vis[u]=0 return r vis[u]=2 return -1 n,m=LI() to=[[] for _ in range(n)] uv=[] for i in range(m): u,v=LI1() to[u].append((v,i)) uv.append((u+1,v+1)) dead=[0]*m seen=[0]*m vis=[0]*n for u in range(n): if vis[u]:continue dfs(u) print(n,m-sum(dead)) for i in range(m): if dead[i]:continue print(*uv[i])