結果

問題 No.2638 Initial fare
ユーザー ニックネームニックネーム
提出日時 2024-02-19 21:28:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,346 ms / 2,000 ms
コード長 284 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 65,664 KB
最終ジャッジ日時 2024-04-17 06:34:09
合計ジャッジ時間 26,616 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,496 KB
testcase_01 AC 35 ms
10,752 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 1,312 ms
61,824 KB
testcase_05 AC 1,346 ms
64,256 KB
testcase_06 AC 31 ms
10,496 KB
testcase_07 AC 1,280 ms
63,872 KB
testcase_08 AC 1,156 ms
61,056 KB
testcase_09 AC 1,220 ms
65,024 KB
testcase_10 AC 1,223 ms
65,536 KB
testcase_11 AC 30 ms
10,624 KB
testcase_12 AC 1,234 ms
63,048 KB
testcase_13 AC 1,065 ms
58,244 KB
testcase_14 AC 1,242 ms
64,768 KB
testcase_15 AC 1,230 ms
65,664 KB
testcase_16 AC 31 ms
10,496 KB
testcase_17 AC 1,220 ms
62,976 KB
testcase_18 AC 1,145 ms
62,848 KB
testcase_19 AC 1,264 ms
63,744 KB
testcase_20 AC 1,239 ms
63,360 KB
testcase_21 AC 1,260 ms
62,592 KB
testcase_22 AC 31 ms
10,752 KB
testcase_23 AC 1,292 ms
62,208 KB
testcase_24 AC 1,309 ms
64,128 KB
testcase_25 AC 31 ms
10,752 KB
testcase_26 AC 1,338 ms
64,000 KB
testcase_27 AC 1,308 ms
63,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x = n = int(input())
uv = [[v-1 for v in map(int,input().split())] for _ in range(n-1)]
adj = [[] for _ in range(n)]
for u,v in uv: adj[u].append(v); adj[v].append(u)
for i in range(n): x += len(adj[i])*(len(adj[i])-1)//2
for u,v in uv: x += (len(adj[u])-1)*(len(adj[v])-1)
print(x-1)
0