| ||||||||||
| 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 | |||||||||
为什么G++超时,而C++却能AC呢?真心请教。#include <stdio.h>
#define MAXV 210
#define INF 10000000
int N;
int Edge[MAXV][MAXV];
int A[MAXV][MAXV];
void floyd()
{
int i,j,k;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
A[i][j]=Edge[i][j];
for(k=0;k<N;k++)
for(i=0;i<N;i++)
for(j=0;j<N;j++)
{
if(k==i||k==j)
continue;
A[i][j]=A[i][j]|(A[i][k]&A[k][j]);
}
}
int main()
{
int i,j,k;
char str[30];
char temp[30];
int total;
int u,v;
while(scanf("%d",&N)!=EOF&&N)
{
for(i=0;i<N;i++)
for(j=0;j<N;j++)
Edge[i][j]=0;
scanf("%d%d",&u,&v);
while(1)
{
if(u==0&&v==0)
break;
u--; v--;
scanf("%s",str);
i=0;
while(str[i]!='\0')
{
Edge[u][v]=(Edge[u][v])|(1<<(str[i]-'a'));
i++;
}
scanf("%d%d",&u,&v);
}
//printf("finished\n");
floyd();
scanf("%d%d",&u,&v);
while(1)
{
if(u==0&&v==0)
break;
u--; v--;
k=0;
total=0;
while(k<26)
{
if(A[u][v]&1)
{
temp[total]=k+'a';
total++;
}
A[u][v]=A[u][v]>>1;
k++;
}
if(total==0)
printf("-\n");
else
{
k=0;
while(k<total)
printf("%c",temp[k++]);
printf("\n");
}
scanf("%d%d",&u,&v);
}
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator