Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

我也犯了楼下的错误，MD.我的代码没毒。

Posted by 983543692 at 2016-06-10 01:25:49 on Problem 2236
```#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int N, d;
struct point{
int x,y;
};
inline bool valid(const point&a,const point&b)
{
int q=a.x-b.x;int w=a.y-b.y;
if(q*q+w*w<=d*d)return true;
else return false;
}
const int maxn=1010;
point result[maxn];
int p[maxn];
bool revive[maxn];
vector<vector<int> >maze;
int find(int x)
{
return p[x]==x?x:p[x]=find(p[x]);
}
void joint(int x,int y)
{
int p1=find(x),p2=find(y);
p[p1]=p2;
}
int main()
{
cin>>N>>d;
maze.resize(N);
memset(revive,0,sizeof(revive));
for(int i=0;i<maxn;i++)p[i]=i;
for(int i=0;i<N;i++)cin>>result[i].x>>result[i].y;
for(int i=0;i<N;i++)
for(int j=i+1;j<N;j++)
if(valid(result[i],result[j]))
maze[i].push_back(j),maze[j].push_back(i);
char ch;
while(cin>>ch)
{
int i,j;
if(ch=='O')
{
cin>>i;
i--;
revive[i]=true;
for(j=0;j<maze[i].size();j++)
{
if(revive[maze[i][j]])
{
joint(maze[i][j],i);
}
}
}
else if(ch=='S')
{
cin>>i>>j;
if(find(i-1)!=find(j-1))cout<<"FAIL"<<endl;
else cout<<"SUCCESS"<<endl;
}
}
return 0;
}```

Followed by: