結果
| 問題 | No.3499 I Love DAG |
| コンテスト | |
| ユーザー |
aorinngo0606
|
| 提出日時 | 2026-04-19 16:10:17 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 619 bytes |
| 記録 | |
| コンパイル時間 | 610 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 46,500 KB |
| 平均クエリ数 | 489.63 |
| 最終ジャッジ日時 | 2026-04-19 16:10:59 |
| 合計ジャッジ時間 | 14,110 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | AC * 15 TLE * 1 -- * 24 |
ソースコード
import sys
sys.setrecursionlimit(10**4)
n, m = map(int, input().split())
g = [[] for i in range(n)]
for _ in range(m):
u, v = map(int, input().split())
u -= 1
v -= 1
g[u].append(v)
cycle = False
def dfs(g, crr, visited, start):
for nxt in g[crr]:
if not visited[nxt]:
visited[nxt] = True
dfs(g, nxt, visited, start)
visited = [False] * n
crr = u
dfs(g, crr, visited, u)
cycle = visited[u]
if cycle:
g[u].pop(-1)
g[v].append(u)
print(1,flush=True)
else:
print(0,flush=True)
aorinngo0606