forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beehives.cpp
50 lines (41 loc) · 1.1 KB
/
beehives.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
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int pythag(pair<double, double> p1, pair<double, double> p2) {
double x = p1.first - p2.first;
double y = p1.second - p2.second;
return sqrt(pow(x, 2) + pow(y, 2));
}
int main() {
double dist;
int hives;
while(cin >> dist && cin >> hives && !(dist == 0 && hives == 0)) {
vector<pair<double, double>> v;
for(int i = 0; i < hives; i++) {
double x, y;
cin >> x >> y;
v.push_back({x, y});
}
int sour = 0, sweet = 0;
for(int i = 0; i < hives; i++) {
bool fight = false;
for(int j = 0; j < hives; j++) {
if(i == j) {
continue;
}
if(pythag(v[i], v[j]) < dist) {
fight = true;
break;
}
}
if(fight) {
sour++;
}
else {
sweet++;
}
}
cout << sour << " sour, " << sweet << " sweet" << endl;
}
}