Submission #6284210


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<int>E[200000];

ll n,K;
ll ans=1;
void dfs(int v,int p,int d,int cnt){
	if(d>=2)(ans*=(K-cnt-2))%=MOD;
	else if(d>=1)(ans*=(K-cnt-1))%=MOD;
	else (ans*=(K-cnt))%=MOD;
	int k=0;
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v,d+1,k);
		k++;
	}
}

int main(){
	cin>>n>>K;
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	dfs(0,-1,0,0);
	cout<<ans<<endl;
}

Submission Info

Submission Time
Task E - Virus Tree 2
User autumn_eel
Language C++14 (GCC 5.4.1)
Score 500
Code Size 653 Byte
Status
Exec Time 42 ms
Memory 12800 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   int a,b;scanf("%d%d",&a,&b);a--;b--;
                              ^

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 500 / 500 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 3 ms 4992 KB
02.txt 3 ms 4992 KB
03.txt 3 ms 4992 KB
04.txt 3 ms 4992 KB
05.txt 3 ms 4992 KB
06.txt 3 ms 4992 KB
07.txt 3 ms 4992 KB
08.txt 3 ms 4992 KB
09.txt 3 ms 4992 KB
10.txt 9 ms 5504 KB
11.txt 14 ms 6016 KB
12.txt 32 ms 7552 KB
13.txt 36 ms 7936 KB
14.txt 36 ms 7936 KB
15.txt 36 ms 7936 KB
16.txt 34 ms 8316 KB
17.txt 34 ms 8316 KB
18.txt 34 ms 8316 KB
19.txt 29 ms 8440 KB
20.txt 29 ms 8440 KB
21.txt 30 ms 8440 KB
22.txt 35 ms 8316 KB
23.txt 35 ms 8316 KB
24.txt 35 ms 8316 KB
25.txt 29 ms 8440 KB
26.txt 29 ms 8440 KB
27.txt 29 ms 8440 KB
28.txt 34 ms 8316 KB
29.txt 34 ms 8316 KB
30.txt 35 ms 8316 KB
31.txt 29 ms 8440 KB
32.txt 29 ms 8440 KB
33.txt 29 ms 8440 KB
34.txt 42 ms 12800 KB
35.txt 42 ms 12672 KB
s1.txt 3 ms 4992 KB
s2.txt 3 ms 4992 KB
s3.txt 3 ms 4992 KB