답안 #634289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
634289 2022-08-24T08:38:23 Z S2speed Subtree (INOI20_subtree) C++17
12 / 100
59 ms 9932 KB
#include<bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")

#define sze(x) (ll)(x.size())
typedef long long ll;
typedef pair<ll , ll> pll;
typedef pair<int , int> pii;

const ll maxn = 1e5 + 17 , md = 1e9 + 7 , inf = 2e16;

ll n , m;
ll dp[maxn];
vector<ll> adj[maxn];

void dDFS(ll r , ll par){
	ll h = 1;
	for(auto i : adj[r]){
		if(i == par) continue;
		dDFS(i , r);
		h *= dp[i] + 1; h %= md;
	}
	dp[r] = h;
	return;
}

void sub2(){
	for(ll i = 1 ; i < n ; i++){
		ll v , u;
		cin>>v>>u; v--; u--;
		adj[v].push_back(u); adj[u].push_back(v);
	}
	dDFS(0 , -1);
	ll ans = 0;
	for(ll i = 0 ; i < n ; i++) ans += dp[i];
	ans %= md;
	cout<<ans<<'\n';
	return;
}

void sub1(){
	return;
}

int main(){
	ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0);

	cin>>n>>m;
	if(m == n - 1) sub2();
	sub1();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 4 ms 3028 KB Output is correct
3 Correct 44 ms 7180 KB Output is correct
4 Correct 37 ms 7080 KB Output is correct
5 Correct 38 ms 7116 KB Output is correct
6 Correct 41 ms 7128 KB Output is correct
7 Correct 59 ms 9272 KB Output is correct
8 Correct 59 ms 8588 KB Output is correct
9 Correct 42 ms 8788 KB Output is correct
10 Correct 29 ms 7704 KB Output is correct
11 Correct 29 ms 7096 KB Output is correct
12 Correct 35 ms 6660 KB Output is correct
13 Correct 37 ms 6488 KB Output is correct
14 Correct 35 ms 8136 KB Output is correct
15 Correct 47 ms 9600 KB Output is correct
16 Correct 48 ms 9932 KB Output is correct
17 Correct 40 ms 6524 KB Output is correct
18 Correct 56 ms 6508 KB Output is correct
19 Correct 39 ms 6612 KB Output is correct
20 Correct 38 ms 7288 KB Output is correct
21 Correct 27 ms 7452 KB Output is correct
22 Correct 30 ms 7372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -