题意:两种操作:A ,R 分别有三个参数,表示放或者移走(x,y)处半径为r的盘子。5000次操作,每次操作判断是否可行。
题解:两种情况不行:1.相交2.放到桌子外面。5000的数据直接模拟,删除操作用e[i]=0代替
//之前一直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.
最后发现是自己y1 == p[i].y写成了y1 = p[i].y...Orz*/
#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; } } }