Submission #468919

#TimeUsernameProblemLanguageResultExecution timeMemory
468919sinamhdvSubtree (INOI20_subtree)C++11
12 / 100
506 ms1048580 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...