|
|
back to boardWhy do I get WA on test 14? I count the components of the graph without reading the bridges.The answer is the amount of the components minus one.I think my algorithm is correct.So why do I get WA on 14 test?Here is my source : #include<iostream> #include<algorithm> using namespace std; int main() { int n,r,w,k,m,i,j,x,y,br=0; int a[10006]; scanf("%d %d %d",&n,&k,&m); for(i=1;i<=n;i++) a[i]=i; for(i=1;i<=k;i++) { scanf("%d %d",&x,&y); if(a[x]==a[y])continue; for(j=1;j<=n;j++) if(a[j]==x)a[j]=y; } sort(a,a+n); for(i=1;i<n;i++) if(a[i]!=a[i+1])br++; printf("%d\n",br); } Can you help me please? I found my mistake That's OK, I found my mistake.It was just a stupid mistake in the source.However, thanks! |
|
|