标签:number cte str namespace res car ssi because stream
Time Limit: 10000MS | Memory Limit: 65536K | |
Total Submissions: 28617 | Accepted: 11842 |
4 1 0 1 0 2 0 3 0 4 O 1 O 2 O 4 S 1 4 O 3 S 1 4
FAIL SUCCESS
1 //2017-07-17 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 6 using namespace std; 7 8 const int N = 1010; 9 int n, d; 10 int fa[N], x[N], y[N]; 11 bool isRepaired[N]; 12 13 void init(){ 14 for(int i = 0; i < N; i++){ 15 fa[i] = i; 16 isRepaired[i] = false; 17 } 18 } 19 20 int getfa(int x){ 21 if(fa[x] == x)return x; 22 return fa[x] = getfa(fa[x]); 23 } 24 25 void merge0(int a, int b){ 26 int af = getfa(a); 27 int bf = getfa(b); 28 if(af != bf){ 29 fa[bf] = af; 30 } 31 } 32 33 int main(){ 34 char op[3]; 35 int a, b; 36 while(scanf("%d%d", &n, &d) != EOF){ 37 init(); 38 for(int i = 1; i <= n; i++){ 39 scanf("%d%d", &x[i], &y[i]); 40 } 41 getchar(); 42 while(scanf("%s", op)!=EOF){ 43 if(op[0] == ‘O‘){ 44 scanf("%d", &a); 45 isRepaired[a] = true; 46 for(int i = 1; i <= n; i++){ 47 if(isRepaired[i] && (x[i]-x[a])*(x[i]-x[a])+(y[i]-y[a])*(y[i]-y[a])<=d*d){ 48 merge0(i, a); 49 } 50 } 51 }else{ 52 scanf("%d%d", &a, &b); 53 int af = getfa(a); 54 int bf = getfa(b); 55 if(af == bf) printf("SUCCESS\n"); 56 else printf("FAIL\n"); 57 } 58 } 59 } 60 61 return 0; 62 }
标签:number cte str namespace res car ssi because stream
原文地址:http://www.cnblogs.com/Penn000/p/7197972.html