| ||||||||||
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 |
int[2000][2000]开在局部,栈空间早爆掉了In Reply To:牛人帮我看一下为什么会runtime error谢谢,实在找不出了 Posted by:majia3 at 2005-07-11 19:32:10 > #include<stdio.h> > #include<memory.h> > #include<math.h> > #include<string.h> > #define Size 2000 > > struct DisjointSet { > long pi[Size], rank[Size]; > > DisjointSet() > { > for (long i = 0; i < Size; i++) { > pi[i] = i; > rank[i] = 0; > } > } > > long find(long x) > { > while (x != pi[x]) > { > x=pi[x]; > } > return pi[x]; > } > > long merge(long x, long y) > { > x = find(x); > y = find(y); > if (rank[x] > rank[y]) { > pi[y] = x; > return x; > } else { > pi[x] = y; > if (rank[x] == rank[y]) rank[y]++; > return y; > } > } > }s; > > int main() > { > long i,n,a[Size][Size],k,k1,k2,j,flag[Size],num; > bool rec[Size]; > double x[Size],y[Size],d; > char str[100]; > scanf("%d %lf",&n,&d); > for (i=1;i<=n;i++) > { > scanf("%lf %lf",&x[i],&y[i]); > for (j=1;j<=i-1;j++) > { > if (sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))<=d) > { > a[i][j]=1; > a[j][i]=1; > } > else > { > a[i][j]=0; > a[j][i]=0; > } > } > } > for (i=1;i<=n;i++) > rec[i]=false; > num=0; > while(scanf("%s",&str)!=NULL) > { > if (strcmp(str,"O")==0) > { > scanf("%d",&k); > if (rec[k]) > continue; > rec[k]=true; > num++; > flag[num]=k; > for (i=1;i<=num-1;i++) > if (a[k][flag[i]]==1) > s.merge(k,flag[i]); > } > else > { > scanf("%d %d",&k1,&k2); > k1=s.find(k1);k2=s.find(k2); > if (k1==k2) > printf("SUCCESS\n"); > else > printf("FAIL\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