-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5371.cpp
More file actions
53 lines (49 loc) · 974 Bytes
/
5371.cpp
File metadata and controls
53 lines (49 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// 5371. Annoying Mosquitos
// 2019.05.21
// 시뮬레이션
#include<iostream>
#include<vector>
using namespace std;
// 모기 구조체 (위치,공격여부)
struct mosquito
{
int x;
int y;
bool attack;
};
int main()
{
int t;
cin >> t;
for (int testCase = 1; testCase <= t; testCase++)
{
int cnt = 0;
int n; // 모기 수
cin >> n;
vector<mosquito> mosquitos; // 모기들의 위치
for (int i = 0; i < n; i++)
{
int x, y;
cin >> x >> y;
mosquitos.push_back({ x,y,false });
}
int m;
cin >> m; // lee가 공격하는 횟수
for (int i = 0; i < m; i++)
{
int x, y;
cin >> x >> y; // lee가 공격하는 좌표
for (int j = 0; j < mosquitos.size(); j++)
{
// 공격 가능하다면
if (abs(mosquitos[j].x - x) <= 50 && abs(mosquitos[j].y - y) <= 50 && !mosquitos[j].attack)
{
cnt++; // 공격한 모기 숫자 증가
mosquitos[j].attack = true;
}
}
}
cout << cnt << endl;
}
return 0;
}