# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
20009 | | ainta | 악수 (kriii4_D) | C++98 | | 4000 ms | 1084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |