# Gym-101375C MaratonIME eats japanese food 初始化struct技巧

2018/03/06 17:04

//之前一直wa 原因不明,大概是写得太复杂。。。

/*吐槽一下vs莫名奇妙的报错if(e[i]==0&& p[i].x == x1&&y1 == p[i].y&&r1 == p[i].r)“必须是可修改的左值。”所以改成了

if(e[i]==0)if (p[i].x == x1)if(y1 == p[i].y)if(r1 == p[i].r)后来改回了去就不报错了，也能ac.

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
using namespace std;
int cnt = 0;
struct plate {
int x, y, r;
plate(int x=0,int y=0,int r=0):x(x),y(y),r(r){}
}p[5005];
bool e[5005];//0 exist
bool ok(struct plate z) {
for (int i = 1; i <= cnt; i++) if(e[i]==0){
if (z.x<0||z.x>1000||z.y<0||z.y>1000||(p[i].r + z.r)*(p[i].r + z.r) > (p[i].x - z.x)*(p[i].x - z.x) + (p[i].y - z.y)*(p[i].y - z.y)) return 0;

}
return 1;
}
int main() {
int t;
cin >> t;

while (t--) {
string s;
cin >> s;
int x1, y1, r1;
cin >> x1 >> y1 >> r1;
if (s == "A") {
if (cnt == 0 || ok(plate(x1, y1, r1)))
{
p[++cnt] = plate(x1, y1, r1);
cout << "Ok" << endl;
}
else cout << "No" << endl;
}
else {
int o = 0;
for (int i = 1; i <= cnt; i++)if(e[i]==0)if (p[i].x == x1)if(y1 == p[i].y)if(r1 == p[i].r) {
e[i] = 1;
cout << "Ok"<<endl;
o = 1; break;
}
if (o == 0)cout << "No" << endl;
}

}

}

0
0 收藏

0 评论
0 收藏
0