-
Notifications
You must be signed in to change notification settings - Fork 24
/
CandyShop.cpp
39 lines (31 loc) · 944 Bytes
/
CandyShop.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
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
class CandyShop {
public:
int m[410][410];
int dist(int x0, int y0, int x, int y) {
return abs(x-x0) + abs(y-y0);
}
int countProbablePlaces(vector <int> X, vector <int> Y, vector <int> R) {
memset(m, 0, sizeof(m));
for (int k = 0; k < X.size(); ++k) {
for (int i = 0; i < 410; ++i) {
for (int j = 0; j < 410; ++j) {
if (dist(X[k]+205, Y[k]+205, j, i) <= R[k])
m[j][i]++;
}
}
}
int res = 0;
for (int i = 0; i < 410; ++i) {
for (int j = 0; j < 410; ++j) {
if (m[j][i] == X.size()) res++;
}
}
return res;
}
};