結果

問題 No.2638 Initial fare
ユーザー 乾麺乾麺
提出日時 2024-04-03 13:18:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 2,250 ms
コンパイル使用メモリ 198,504 KB
実行使用メモリ 21,272 KB
最終ジャッジ日時 2024-04-03 13:18:20
合計ジャッジ時間 10,472 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 284 ms
19,812 KB
testcase_05 AC 322 ms
20,760 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 254 ms
20,596 KB
testcase_18 WA -
testcase_19 AC 283 ms
20,696 KB
testcase_20 AC 275 ms
20,644 KB
testcase_21 AC 287 ms
20,244 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 299 ms
20,036 KB
testcase_24 AC 309 ms
20,504 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 307 ms
20,632 KB
testcase_27 AC 331 ms
20,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using si =vector<char>;
using ssi =vector<si>;
//using mint = modint998244353;
const long long INF = 1e18;
//bit全探索 rep(i,0,1<<(n-1)){rep(j,0,n-1)if(I&(1<<j))}
//int a = s[0] - ‘0’;文字列から数字
//int a=atoi(s.c_str());
//“ABCDEFGHIJKLMNOPQRSTUVWXYZ"
//ll l-=-1,r=2e9;
//while (r - l > 1) {
//    ll m = (l + r) / 2;
//    (m * (m + 1) / 2 <= n + 1 ? l : r) = m;
//  }
int main() { int n;
cin>>n;
vvi vec(n);
rep(i,0,n-1){
	int a,b;
	cin>>a>>b;
	a--;b--;
	vec[a].push_back(b);
	vec[b].push_back(a);
}
int ans=n-1;int bf=0;
rep(i,0,n){
int c=vec[i].size()	;
bf+=c*(c-1)/2;
}
int d=0;
rep(i,0,n){
	for(auto z:vec[i]){
d+=(vec[i].size()-1)*(vec[z].size()-1);	
	}
}
d/=2;
cout<<ans+bf+d;
}
0