[기억하면 좋을 것들]
벡터에서 j번째 값을 지우고 싶다면
v.erase(v.begin() + j);
문자 하나를 입력 받을 때 string으로 입력 받고 [0]에 접근하면 실수를 줄일 수 있다.
pair형 벡터에 값을 넣으려면 v.emplace(x, y);
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;
using i64 = long long;
using ii = pair<int, int>;
int main()
{
int n;
char tmp;
scanf("%d", &n);
vector<ii> pos;
vector<int> radius;
for (int i = 0; i < n; i++)
{
string type;
int x, y, r;
cin >> type >> x >> y >> r;
if (type[0] == 'A')
{
bool check = true;
for (int j = 0; j < pos.size(); j++)
{
if ((r + radius[j])*(r + radius[j]) > (x - pos[j].first)*(x - pos[j].first) + (y - pos[j].second)*(y - pos[j].second))
{
check = false;
break;
}
}
if (check)
{
pos.emplace_back(x, y);
radius.push_back(r);
printf("Ok\n");
}
else
printf("No\n");
}
else
{
bool check = false;
for (int j = 0; j < pos.size(); j++)
{
if (r == radius[j] && x == pos[j].first && y == pos[j].second)
{
pos.erase(pos.begin() + j);
radius.erase(radius.begin() + j);
check = true;
break;
}
}
if (check)
{
printf("Ok\n");
}
else
printf("No\n");
}
}
return 0;
}
'UCPC' 카테고리의 다른 글
[20/05/17] E. MaratonIME does (not do) PAs (0) | 2020.05.20 |
---|---|
[20/05/17] D. MaratonIME in the golden moment (0) | 2020.05.20 |
[20/05/17] B. MaratonIME challenges USPGameDev (0) | 2020.05.20 |
[20/05/17] A. MaratonIME stacks popcorn buckets (0) | 2020.05.20 |
[20/05/17] 첫 번째 ucpc 연습 후기 (0) | 2020.05.20 |