# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155631 | 2019-09-29T11:48:36 Z | Akashi | The Forest of Fangorn (CEOI14_fangorn) | C++14 | 1075 ms | 65056 KB |
#include <bits/stdc++.h> using namespace std; const long double pi = 3.1415926535897; int w, h; int n, c, xG, yG; int x[2005], y[2005], x2[10005], y2[10005]; long double ang[10005]; vector <long double> v[2005]; vector <int> sol; inline long double angle(long double x, long double y){ long double r = sqrt(x * x + y * y); x = x / r; y = y / r; long double alpha = acos(x); if(y < 0) alpha = 2.0 * pi - alpha; return alpha; } inline bool check(int j, long double alpha1, long double alpha2){ vector <long double> :: iterator it = lower_bound(v[j].begin(), v[j].end(), alpha1); if(it == v[j].end()) return 1; if(*it <= alpha2) return 0; return 1; } int main() { // freopen("1.in", "r", stdin); scanf("%d%d", &w, &h); scanf("%d%d", &xG, &yG); scanf("%d", &c); for(int i = 1; i <= c ; ++i) scanf("%d%d", &x2[i], &y2[i]); scanf("%d", &n); for(int i = 1; i <= n ; ++i) scanf("%d%d", &x[i], &y[i]); for(int i = 1; i <= n ; ++i){ for(int j = i + 1; j <= n ; ++j){ v[j].push_back(angle(x[i] - x[j], y[i] - y[j])); v[i].push_back(angle(x[j] - x[i], y[j] - y[i])); } } for(int i = 1; i <= n ; ++i) sort(v[i].begin(), v[i].end()); for(int i = 1; i <= n ; ++i) ang[i] = angle(xG - x[i], yG - y[i]); for(int i = 1; i <= c ; ++i){ bool ok = true; for(int j = 1; j <= n && ok ; ++j){ long double alpha1 = ang[j]; long double alpha2 = angle(x2[i] - x[j], y2[i] - y[j]); if(alpha1 > alpha2) swap(alpha1, alpha2); if(alpha2 - alpha1 <= pi) ok = check(j, alpha1, alpha2); else ok = min(check(j, 0.0, alpha1), check(j, alpha2, 2 * pi)); } if(ok) sol.push_back(i); } printf("%d\n", sol.size()); for(auto it : sol) printf("%d ", it); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Incorrect | 2 ms | 504 KB | Output isn't correct |
6 | Incorrect | 3 ms | 376 KB | Output isn't correct |
7 | Correct | 4 ms | 504 KB | Output is correct |
8 | Incorrect | 3 ms | 504 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Incorrect | 3 ms | 376 KB | Output isn't correct |
3 | Incorrect | 3 ms | 504 KB | Output isn't correct |
4 | Correct | 3 ms | 632 KB | Output is correct |
5 | Correct | 4 ms | 504 KB | Output is correct |
6 | Correct | 7 ms | 1016 KB | Output is correct |
7 | Incorrect | 2 ms | 376 KB | Output isn't correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Incorrect | 3 ms | 504 KB | Output isn't correct |
10 | Incorrect | 10 ms | 1144 KB | Output isn't correct |
11 | Incorrect | 11 ms | 1144 KB | Output isn't correct |
12 | Correct | 11 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Incorrect | 2 ms | 504 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1075 ms | 65056 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |