| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
why wa...求一组错的测试数据#include<stdio.h>
int h[251][251],g[201][201],d[30];
int main(){
int m,n,l,i,j,k,t,a,b,ans=5000;
scanf("%d%d%d",&m,&n,&l);
for(i=0;i<l;i++)scanf("%d",&d[i]);
for(i=1;i<=m;i++){
for(j=1;j<=m;j++)g[i][j]=5000;
g[i][i]=0;
}
for(i=1;i<=m;i++){
scanf("%d%d",&j,&a);
t=a;
while(j---1){
scanf("%d",&b);
h[a][b]=i;
if(h[b][a]&&h[b][a]!=h[a][b])g[h[b][a]][h[a][b]]=g[h[a][b]][h[b][a]]=1;
a=b;
}
b=t;
h[a][b]=i;
if(h[b][a]&&h[b][a]!=h[a][b])g[h[b][a]][h[a][b]]=g[h[a][b]][h[b][a]]=1;
}
for(i=1;i<=m;i++)for(j=1;j<=m;j++)for(k=1;k<=m;k++)
if(g[i][k]+g[k][j]<g[i][j])g[i][j]=g[i][k]+g[k][j];
for(i=1;i<=m;i++){
t=0;
for(j=0;j<l;j++){
a=5000;
for(k=1;k<=n;k++){
if(h[k][d[j]]&&g[h[k][d[j]]][i]<a)a=g[h[k][d[j]]][i];
if(h[d[j]][k]&&g[h[d[j]][k]][i]<a)a=g[h[d[j]][k]][i];
}
t+=a;
}
if(t<ans)ans=t;
}
printf("%d\n",ans);
return 0;
}
自己很无奈,构造了多组,都是对的...
floyd+枚举做的
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator