結果

問題 No.1507 Road Blocked
ユーザー chocoruskchocorusk
提出日時 2021-05-14 23:00:03
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 3,012 ms
使用メモリ 17,092 KB
最終ジャッジ日時 2022-11-25 21:03:11
合計ジャッジ時間 6,119 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 3 ms
5,912 KB
testcase_01 AC 3 ms
5,916 KB
testcase_02 AC 3 ms
5,768 KB
testcase_03 AC 64 ms
17,092 KB
testcase_04 AC 68 ms
9,412 KB
testcase_05 AC 66 ms
9,336 KB
testcase_06 AC 65 ms
9,344 KB
testcase_07 AC 64 ms
9,464 KB
testcase_08 AC 66 ms
9,460 KB
testcase_09 AC 66 ms
9,344 KB
testcase_10 AC 64 ms
9,484 KB
testcase_11 AC 65 ms
9,480 KB
testcase_12 AC 69 ms
9,404 KB
testcase_13 AC 67 ms
9,336 KB
testcase_14 AC 65 ms
9,400 KB
testcase_15 AC 63 ms
9,424 KB
testcase_16 AC 67 ms
9,440 KB
testcase_17 AC 68 ms
9,460 KB
testcase_18 AC 65 ms
9,432 KB
testcase_19 AC 65 ms
9,340 KB
testcase_20 AC 65 ms
9,344 KB
testcase_21 AC 63 ms
9,336 KB
testcase_22 AC 64 ms
9,452 KB
testcase_23 AC 65 ms
9,344 KB
testcase_24 AC 64 ms
9,332 KB
testcase_25 AC 66 ms
9,336 KB
testcase_26 AC 65 ms
9,508 KB
testcase_27 AC 70 ms
9,492 KB
testcase_28 AC 69 ms
9,448 KB
testcase_29 AC 66 ms
9,464 KB
testcase_30 AC 65 ms
9,336 KB
testcase_31 AC 65 ms
9,384 KB
testcase_32 AC 65 ms
9,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int n;
vector<int> g[100010];
int c[100010];
using mint=modint998244353;
mint ans;
mint t;
void dfs(int x, int p){
	c[x]=1;
	for(auto y:g[x]){
		if(y==p) continue;
		dfs(y, x);
		c[x]+=c[y];
		ans+=mint(c[y])*mint(n-c[y])*t;
	}

}
int main()
{
    cin>>n;
	t=mint(n)*mint(n-1)/mint(2)*mint(n-1);
	t=t.inv();
	for(int i=0; i<n-1; i++){
		int a, b;
		cin>>a>>b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0, -1);
	ans=1-ans;
	cout<<ans.val()<<endl;
    return 0;
}
0