| ||||||||||
| 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 | |||||||||
Re:好心人能不能帮我看下啊,我弄了一个下午还是WA,真不知哪里错了,真的好崩溃啊,万分感谢各位啊In Reply To:好心人能不能帮我看下啊,我弄了一个下午还是WA,真不知哪里错了,真的好崩溃啊,万分感谢各位啊 Posted by:20062449 at 2008-07-28 17:21:06 > #include<iostream>
> #include<string>
> using namespace std;
> struct sign_data
> {
> char chardata;
> };
> sign_data sign[500000];
> int pare[500000],n,d;
> int cfind(int x)
> {
> if(x!=1)
> {
> if(sign[x].chardata=='O')
> {
> for(int i=x-1;i>=(x-d)&&(i>=1);i--)
> {
> if(sign[i].chardata=='O'){pare[x]=i;return pare[x];}
> }
> }
> else pare[x]=x;
> }
> else pare[x]=x;
> return pare[x];
> }
> int un_ion(int x,int y)
> {
> while(cfind(x)!=x)x=pare[x];
> while(cfind(y)!=y)y=pare[y];
> if(x==y){cout<<"SUCCESS"<<endl;return 1;}
> else {cout<<"FAIL"<<endl;return 1;}
> }
> int main()
> {
> for(int i=1;i<500000;i++)
> {pare[i]=i;}
> cin>>n>>d;
> int x,y,j=0,x1,y1;
> char z,z1;
> while(j<n)
> {
> cin>>x>>y;
> j++;
> }
> while( cin>>z)
> {
> if(z=='O'){cin>>x;sign[x].chardata='O';}
> if(z=='S'){
> cin>>x>>y;
> un_ion(x,y);
> //cout<<sign[5].chardata;
>
> }
> }
> //system("pause");
> return 1;
> }
哇,ls合工大的,,我也是合肥的耶
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator