Submission #1003162

#TimeUsernameProblemLanguageResultExecution timeMemory
1003162vjudge1Subtree (INOI20_subtree)C++17
12 / 100
469 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define all(v) v.begin(), v.end() #define oo 1e9 const int MAX = 1e5 + 5, MOD = 1e9 + 7; int n, m; vector<int> g[MAX]; int dp[MAX]; void dfs(int node, int p){ dp[node] = 1; for(int to : g[node]){ if(to == p) continue; dfs(to, node); dp[node] = dp[node] * (dp[to] + 1) % MOD; } } void solve(){ cin >> n >> m; for(int i = 1; i <= m; i++){ int u, v; cin >> u >> v; g[u].push_back(v); g[v].push_back(u); } dfs(1, 1); int ans = 0; for(int i = 1; i <= n; i++){ ans = (ans + dp[i]) % MOD; } cout << ans << '\n'; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...