Created
May 27, 2018 12:02
-
-
Save taichunmin/7c3068520c751a7da6d7f7724f8bfcee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cstdio> | |
| #include <string> | |
| #include <vector> | |
| #include <algorithm> | |
| using namespace std; | |
| /** | |
| * Auto-generated code below aims at helping you parse | |
| * the standard input according to the problem statement. | |
| **/ | |
| struct Apple { | |
| int x, y, z; | |
| long long r; | |
| }; | |
| bool hasCollide(Apple tmp, Apple b) { | |
| int x = tmp.x - b.x, y = tmp.y - b.y, r = tmp.r + b.r; | |
| return ((x*x + y*y) < r*r) && tmp.z > b.z; | |
| } | |
| void debugApple (Apple a) { | |
| printf("(%d, %d, %d, %lld)", a.x, a.y, a.z, a.r); | |
| } | |
| int main() | |
| { | |
| int N, index, s_cnt; | |
| Apple apples[100], stack[100]; | |
| cin >> N >> index; | |
| for (int i = 0; i < N; i++) { | |
| int x, y, z; | |
| long long r; | |
| cin >> x >> y >> z >> r; | |
| apples[i] = {x, y, z, r}; | |
| } | |
| s_cnt = 1; | |
| stack[0] = apples[index]; | |
| apples[index] = apples[--N]; | |
| //debugApple(stack[0]); | |
| while(s_cnt > 0) { | |
| Apple tmp = stack[--s_cnt]; | |
| for (int i=0; i<N; i++) | |
| if (hasCollide(tmp, apples[i])) { | |
| stack[s_cnt++] = apples[i]; | |
| apples[i--] = apples[--N]; | |
| } | |
| } | |
| cout << N << endl; | |
| } | |
| /* | |
| 3 0 | |
| 0 0 150 7 | |
| 0 10 100 7 | |
| 0 -10 100 7 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment