結果
問題 | No.1480 Many Complete Graphs |
ユーザー | mkawa2 |
提出日時 | 2022-11-04 17:51:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 323 ms / 2,000 ms |
コード長 | 1,682 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 94,264 KB |
最終ジャッジ日時 | 2024-07-18 16:15:47 |
合計ジャッジ時間 | 12,230 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,320 KB |
testcase_01 | AC | 39 ms
54,124 KB |
testcase_02 | AC | 40 ms
54,920 KB |
testcase_03 | AC | 38 ms
54,080 KB |
testcase_04 | AC | 34 ms
54,004 KB |
testcase_05 | AC | 33 ms
54,824 KB |
testcase_06 | AC | 37 ms
54,344 KB |
testcase_07 | AC | 36 ms
52,948 KB |
testcase_08 | AC | 36 ms
53,816 KB |
testcase_09 | AC | 54 ms
67,908 KB |
testcase_10 | AC | 49 ms
65,820 KB |
testcase_11 | AC | 40 ms
55,328 KB |
testcase_12 | AC | 44 ms
61,424 KB |
testcase_13 | AC | 57 ms
76,440 KB |
testcase_14 | AC | 54 ms
72,840 KB |
testcase_15 | AC | 181 ms
84,752 KB |
testcase_16 | AC | 135 ms
83,840 KB |
testcase_17 | AC | 144 ms
82,548 KB |
testcase_18 | AC | 97 ms
81,452 KB |
testcase_19 | AC | 139 ms
82,272 KB |
testcase_20 | AC | 164 ms
81,700 KB |
testcase_21 | AC | 67 ms
81,564 KB |
testcase_22 | AC | 52 ms
71,668 KB |
testcase_23 | AC | 76 ms
84,096 KB |
testcase_24 | AC | 177 ms
81,648 KB |
testcase_25 | AC | 226 ms
86,196 KB |
testcase_26 | AC | 226 ms
88,440 KB |
testcase_27 | AC | 164 ms
82,448 KB |
testcase_28 | AC | 159 ms
93,900 KB |
testcase_29 | AC | 161 ms
93,496 KB |
testcase_30 | AC | 153 ms
93,512 KB |
testcase_31 | AC | 161 ms
93,380 KB |
testcase_32 | AC | 164 ms
93,560 KB |
testcase_33 | AC | 166 ms
93,660 KB |
testcase_34 | AC | 168 ms
93,740 KB |
testcase_35 | AC | 194 ms
94,164 KB |
testcase_36 | AC | 189 ms
93,592 KB |
testcase_37 | AC | 198 ms
93,584 KB |
testcase_38 | AC | 211 ms
93,468 KB |
testcase_39 | AC | 225 ms
94,264 KB |
testcase_40 | AC | 189 ms
93,936 KB |
testcase_41 | AC | 195 ms
93,652 KB |
testcase_42 | AC | 201 ms
94,148 KB |
testcase_43 | AC | 230 ms
93,568 KB |
testcase_44 | AC | 212 ms
93,612 KB |
testcase_45 | AC | 211 ms
93,744 KB |
testcase_46 | AC | 210 ms
94,000 KB |
testcase_47 | AC | 295 ms
93,232 KB |
testcase_48 | AC | 267 ms
93,284 KB |
testcase_49 | AC | 251 ms
92,952 KB |
testcase_50 | AC | 110 ms
90,276 KB |
testcase_51 | AC | 312 ms
93,672 KB |
testcase_52 | AC | 248 ms
91,956 KB |
testcase_53 | AC | 298 ms
93,072 KB |
testcase_54 | AC | 323 ms
93,120 KB |
testcase_55 | AC | 316 ms
93,088 KB |
testcase_56 | AC | 283 ms
92,764 KB |
testcase_57 | AC | 126 ms
89,792 KB |
testcase_58 | AC | 114 ms
91,544 KB |
evil_aftercontest.txt | AC | 167 ms
108,620 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) 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 << 63)-1 # inf = (1 << 31)-1 # md = 10**9+7 md = 998244353 from heapq import * n, m = LI() gg = [[] for _ in range(n+1)] cc = [] mem = [] for g in range(m): k, c, *ss = LI() cc.append(c) mem.append(ss[::-1]) for s in ss: gg[s].append(g) hp = [] dist = [inf]*(n+1) dist[1] = 0 mns = [inf]*m mnu = [-1]*m fin = [0]*(n+1) fin[1] = 1 for g in gg[1]: mns[g] = 1 mnu[g] = 1 mem[g].pop() v = mem[g][-1] d = (v+2)//2+cc[g] dist[v] = d heappush(hp, (d, v)) def update(g): while mem[g] and fin[mem[g][-1]]: mem[g].pop() if not mem[g]: return u = mnu[g] v = mem[g][-1] nd = dist[u]+(u+v+1)//2+cc[g] if nd < dist[v]: dist[v] = nd heappush(hp, (nd, v)) while hp: d, u = heappop(hp) if u == n: break if d > dist[u]: continue fin[u] = 1 for g in gg[u]: cur = d*2+u if cur < mns[g]: mns[g], mnu[g] = cur, u update(g) # pDB(hp, mem) ans = dist[-1] if ans == inf: ans = -1 print(ans)