結果
| 問題 |
No.2638 Initial fare
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-22 22:36:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 512 bytes |
| コンパイル時間 | 689 ms |
| コンパイル使用メモリ | 74,308 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-29 04:29:11 |
| 合計ジャッジ時間 | 3,034 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include<iostream>
#include<cstdio>
#include<utility>
#include<map>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
int _;
int n,m,q,ccf;
int l[200010];
int r[200010];
long long d[200010];
long long ans;
int main()
{
ios::sync_with_stdio(false);
cin>>n;
for (int i=1; i<n; i++)
{
cin>>l[i]>>r[i];
d[l[i]]++;
d[r[i]]++;
}
ans=n-1;
for (int i=1; i<=n; i++)
ans=ans+d[i]*(d[i]-1)/2;
for (int i=1; i<n; i++)
ans=ans+(d[l[i]]-1)*(d[r[i]]-1);
cout<<ans;
return 0;
}