#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int pw(int a,int b){
int ans=1;
while(b){
if(b&1){
ans=ans*a%mod;
}
b>>=1;
a=a*a%mod;
}
return ans;
}
vector<vector<int>> adj;
vector<int> dp;
void dfs(int k,int pa){
bool flag=0;
for(int j:adj[k]){
if(j==pa){
continue;
}
dfs(j,k);
if(dp[j]==0){
flag=1;
}
}
dp[k]=flag;
}
signed main(){
int n;cin>>n;
int d;cin>>d;
if(n==2){
int p=pw(2,d*2);
cout<<p<<endl;
return 0;
}
adj.resize(n*2);
for(int i=1;i<n;i++){
int a,b;cin>>a>>b;a--;b--;
adj[a].push_back(b);
adj[b].push_back(a);
adj[n+a].push_back(n+b);
adj[n+b].push_back(n+a);
}
int ans=0;
for(int i=0;i<n;i++){
for(int j=n;j<n*2;j++){
adj[i].push_back(j);
dp.assign(n*2,-1);
dfs(0,0);
if(dp[0]==1){
ans++;
}
adj[i].pop_back();
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1079 ms |
428 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
16 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
316 KB |
Output is correct |
4 |
Correct |
16 ms |
212 KB |
Output is correct |
5 |
Correct |
16 ms |
300 KB |
Output is correct |
6 |
Correct |
16 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
16 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
316 KB |
Output is correct |
4 |
Correct |
16 ms |
212 KB |
Output is correct |
5 |
Correct |
16 ms |
300 KB |
Output is correct |
6 |
Correct |
16 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
1077 ms |
484 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
16 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
316 KB |
Output is correct |
4 |
Correct |
16 ms |
212 KB |
Output is correct |
5 |
Correct |
16 ms |
300 KB |
Output is correct |
6 |
Correct |
16 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
1077 ms |
484 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
16 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
316 KB |
Output is correct |
4 |
Correct |
16 ms |
212 KB |
Output is correct |
5 |
Correct |
16 ms |
300 KB |
Output is correct |
6 |
Correct |
16 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
1077 ms |
484 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
296 KB |
Output is correct |
2 |
Correct |
16 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
316 KB |
Output is correct |
4 |
Correct |
16 ms |
212 KB |
Output is correct |
5 |
Correct |
16 ms |
300 KB |
Output is correct |
6 |
Correct |
16 ms |
212 KB |
Output is correct |
7 |
Execution timed out |
1077 ms |
484 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1079 ms |
428 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |