# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
20009 |
2016-02-25T08:25:50 Z |
ainta |
악수 (kriii4_D) |
C++ |
|
4000 ms |
1084 KB |
#include<stdio.h>
int n, F[11], cnt;
long long Mod = 1000000007, Res;
bool E[11][11], v[11];
long long Pow(long long a, int b){
long long r = 1;
while(b){
if(b&1)r=r*a%Mod;
a=a*a%Mod;
b>>=1;
}
return r;
}
void DFS(int a){
cnt++;
v[a]=true;
int i;
for(i=1;i<=n;i++)if(!v[i]&&E[a][i])DFS(i);
}
void Do(int cc){
int i,j;
cnt = 0;
for(i=1;i<=n;i++)v[i]=false;
DFS(1);
if(cnt == n){
Res = (Res + cc*Pow(F[n*(n-1)/2]/F[n*(n-1)/2-cc],Mod-2))%Mod;
return;
}
for(i=1;i<n;i++){
for(j=i+1;j<=n;j++){
if(!E[i][j]){
E[i][j]=E[j][i]=1;
Do(cc+1);
E[i][j]=E[j][i]=0;
}
}
}
}
int main(){
int i;
F[0]=1;
for(i=1;i<=10;i++)F[i]=F[i-1]*i;
scanf("%d",&n);
Do(0);
printf("%lld\n",Res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Correct |
0 ms |
1084 KB |
Output is correct |
3 |
Correct |
0 ms |
1084 KB |
Output is correct |
4 |
Correct |
0 ms |
1084 KB |
Output is correct |
5 |
Correct |
37 ms |
1084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4000 ms |
1080 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |