Submission #468919

# Submission time Handle Problem Language Result Execution time Memory
468919 2021-08-30T07:52:42 Z sinamhdv Subtree (INOI20_subtree) C++11
12 / 100
506 ms 1048580 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1e9 + 100;
const ll LINF = 1e18 + 100;

#ifdef DEBUG
#define dbg(x) cout << #x << " = " << (x) << endl << flush;
#define dbgr(s, f) { cout << #s << ": "; for (auto _ = (s); _ != (f); _++) cout << *_ << ' '; cout << endl << flush; }
#else
#define dbg(x) ;
#define dbgr(s, f) ;
#endif
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int MAXN = 100100;
const int MAXE = 150100;

int n, m;
vector<int> adj[MAXN];
int dp[MAXN][2];

void dfs(int v, int par)
{
	int cur = 1;
	for (int u : adj[v]) if (u != par)
	{
		dfs(u, v);
		cur = (ll)cur * (dp[u][1] + 1) % mod;
		dp[v][0] = (dp[v][0] + dp[u][0]) % mod;
	}
	dp[v][1] = cur;
	dp[v][0] = (dp[v][0] + cur) % mod;
}

int32_t main(void)
{
	fast_io;
	cin >> n >> m;
	FOR(i, 0, m)
	{
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}

	dfs(1, -1);

	cout << dp[1][0] << endl;
	return 0;
}


# Verdict Execution time Memory Grader output
1 Runtime error 506 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 5 ms 3068 KB Output is correct
3 Correct 60 ms 7800 KB Output is correct
4 Correct 58 ms 7720 KB Output is correct
5 Correct 52 ms 7756 KB Output is correct
6 Correct 63 ms 7828 KB Output is correct
7 Correct 58 ms 13308 KB Output is correct
8 Correct 61 ms 11224 KB Output is correct
9 Correct 70 ms 11308 KB Output is correct
10 Correct 46 ms 8332 KB Output is correct
11 Correct 46 ms 7976 KB Output is correct
12 Correct 61 ms 7648 KB Output is correct
13 Correct 57 ms 7844 KB Output is correct
14 Correct 46 ms 10300 KB Output is correct
15 Correct 57 ms 14220 KB Output is correct
16 Correct 73 ms 15020 KB Output is correct
17 Correct 59 ms 7744 KB Output is correct
18 Correct 67 ms 7748 KB Output is correct
19 Correct 61 ms 7756 KB Output is correct
20 Correct 43 ms 7984 KB Output is correct
21 Correct 49 ms 8176 KB Output is correct
22 Correct 40 ms 8040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 506 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 506 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -