結果

問題 No.1507 Road Blocked
ユーザー chocoruskchocorusk
提出日時 2021-05-14 23:00:03
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 3,571 ms
コンパイル使用メモリ 186,236 KB
実行使用メモリ 17,216 KB
最終ジャッジ日時 2024-04-10 02:18:26
合計ジャッジ時間 8,125 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 4 ms
6,944 KB
testcase_02 AC 4 ms
6,944 KB
testcase_03 AC 77 ms
17,216 KB
testcase_04 AC 101 ms
9,344 KB
testcase_05 AC 101 ms
9,472 KB
testcase_06 AC 98 ms
9,544 KB
testcase_07 AC 102 ms
9,600 KB
testcase_08 AC 101 ms
9,472 KB
testcase_09 AC 97 ms
9,544 KB
testcase_10 AC 95 ms
9,472 KB
testcase_11 AC 93 ms
9,600 KB
testcase_12 AC 90 ms
9,472 KB
testcase_13 AC 88 ms
9,472 KB
testcase_14 AC 92 ms
9,472 KB
testcase_15 AC 92 ms
9,472 KB
testcase_16 AC 100 ms
9,344 KB
testcase_17 AC 94 ms
9,472 KB
testcase_18 AC 90 ms
9,436 KB
testcase_19 AC 91 ms
9,412 KB
testcase_20 AC 94 ms
9,344 KB
testcase_21 AC 92 ms
9,344 KB
testcase_22 AC 94 ms
9,472 KB
testcase_23 AC 93 ms
9,472 KB
testcase_24 AC 95 ms
9,472 KB
testcase_25 AC 92 ms
9,668 KB
testcase_26 AC 92 ms
9,472 KB
testcase_27 AC 90 ms
9,344 KB
testcase_28 AC 90 ms
9,472 KB
testcase_29 AC 93 ms
9,344 KB
testcase_30 AC 95 ms
9,540 KB
testcase_31 AC 97 ms
9,472 KB
testcase_32 AC 93 ms
9,344 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