Submission #1003093

# Submission time Handle Problem Language Result Execution time Memory
1003093 2024-06-20T05:59:03 Z vjudge1 Subtree (INOI20_subtree) C++17
12 / 100
560 ms 1048576 KB
#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 time Memory Grader output
1 Runtime error 560 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 3 ms 3264 KB Output is correct
3 Correct 26 ms 8324 KB Output is correct
4 Correct 28 ms 8276 KB Output is correct
5 Correct 44 ms 8280 KB Output is correct
6 Correct 43 ms 8276 KB Output is correct
7 Correct 41 ms 12372 KB Output is correct
8 Correct 26 ms 11200 KB Output is correct
9 Correct 36 ms 11092 KB Output is correct
10 Correct 21 ms 9048 KB Output is correct
11 Correct 20 ms 8352 KB Output is correct
12 Correct 25 ms 8024 KB Output is correct
13 Correct 25 ms 7688 KB Output is correct
14 Correct 23 ms 10188 KB Output is correct
15 Correct 28 ms 13144 KB Output is correct
16 Correct 29 ms 13648 KB Output is correct
17 Correct 25 ms 7760 KB Output is correct
18 Correct 26 ms 7772 KB Output is correct
19 Correct 28 ms 7780 KB Output is correct
20 Correct 22 ms 8400 KB Output is correct
21 Correct 20 ms 8660 KB Output is correct
22 Correct 23 ms 8480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 560 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 560 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -