# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003162 |
2024-06-20T07:01:00 Z |
vjudge1 |
Subtree (INOI20_subtree) |
C++17 |
|
469 ms |
1048576 KB |
#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 time |
Memory |
Grader output |
1 |
Runtime error |
469 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
3 ms |
3164 KB |
Output is correct |
3 |
Correct |
24 ms |
8284 KB |
Output is correct |
4 |
Correct |
26 ms |
8376 KB |
Output is correct |
5 |
Correct |
27 ms |
8484 KB |
Output is correct |
6 |
Correct |
24 ms |
8284 KB |
Output is correct |
7 |
Correct |
30 ms |
12380 KB |
Output is correct |
8 |
Correct |
28 ms |
11100 KB |
Output is correct |
9 |
Correct |
27 ms |
11092 KB |
Output is correct |
10 |
Correct |
21 ms |
9052 KB |
Output is correct |
11 |
Correct |
25 ms |
8388 KB |
Output is correct |
12 |
Correct |
25 ms |
7768 KB |
Output is correct |
13 |
Correct |
25 ms |
7772 KB |
Output is correct |
14 |
Correct |
22 ms |
10176 KB |
Output is correct |
15 |
Correct |
29 ms |
13032 KB |
Output is correct |
16 |
Correct |
29 ms |
13660 KB |
Output is correct |
17 |
Correct |
25 ms |
7772 KB |
Output is correct |
18 |
Correct |
29 ms |
7752 KB |
Output is correct |
19 |
Correct |
23 ms |
7772 KB |
Output is correct |
20 |
Correct |
20 ms |
8400 KB |
Output is correct |
21 |
Correct |
20 ms |
8668 KB |
Output is correct |
22 |
Correct |
28 ms |
8556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
469 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
469 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |