forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplat.cpp
56 lines (45 loc) · 1.03 KB
/
splat.cpp
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
54
55
56
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
struct color {
double x;
double y;
double v;
string col;
};
double getdistance(double x, double y, color k) {
return sqrt(pow(x-k.x,2) + pow(y-k.y,2));
}
double inrange(double dist, color k) {
return dist < sqrt(k.v / M_PI);
}
int main() {
int n;
cin >> n;
for(int i = 0; i < n; i++) {
int c;
cin >> c;
vector<color> v;
for(int j = 0; j < c; j++) {
color temp;
cin >> temp.x >> temp.y >> temp.v >> temp.col;
v.push_back(temp);
}
int d;
cin >> d;
for(int j = 0; j < d; j++) {
string closest = "white";
double x, y;
cin >> x >> y;
for(auto k : v) {
double dist = getdistance(x, y, k);
if(inrange(dist, k)) {
closest = k.col;
}
}
cout << closest << endl;
}
}
}