이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |