Submission #1003093

#TimeUsernameProblemLanguageResultExecution timeMemory
1003093vjudge1Subtree (INOI20_subtree)C++17
12 / 100
560 ms1048576 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define endl "\n" using namespace std; using namespace __gnu_pbds; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; const ll N = 1e5 + 5, mod = 1e9 + 7; vector<ll> g[N]; ll dp[N]; void dfs(ll v, ll par = 0) { dp[v] = 1; for (ll to : g[v]) if (to != par) dfs(to, v), dp[v] = (dp[to] + 1) * dp[v] % mod; } void solve() { ll n, m; cin >> n >> m; while (m--) { ll a, b; cin >> a >> b; g[a].push_back(b); g[b].push_back(a); } dfs(1); ll ans = 0; for (ll i = 1; i <= n; i++) ans = (ans + dp[i]) % mod; cout << ans << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll t = 1; // precomp(); // cin >> t; for (ll cs = 1; cs <= t; cs++) solve(); // cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...