結果

問題 No.2638 Initial fare
ユーザー moon17moon17
提出日時 2024-02-19 23:02:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 325 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 284,288 KB
最終ジャッジ日時 2024-02-19 23:02:15
合計ジャッジ時間 6,749 ms
ジャッジサーバーID
(参考情報)
judge16 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
60,264 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 43 ms
62,224 KB
testcase_04 AC 1,117 ms
98,184 KB
testcase_05 AC 1,154 ms
99,404 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
g=[[]for _ in range(n)]
for _ in range(n-1):
  u,v=map(int,input().split())
  g[u-1]+=v-1,
  g[v-1]+=u-1,
ans=0
for i in range(n):
  q=[(0,i)]
  s={i}
  while q:
    t,p=q.pop()
    if t==3:
      continue
    for v in g[p]:
      if v not in s:
        q+=(t+1,v),
        s|={v}
  ans+=len(s)-1
print(ans//2)
0