# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
388521 | 2021-04-11T21:34:28 Z | LucaDantas | The Forest of Fangorn (CEOI14_fangorn) | C++17 | 3000 ms | 844 KB |
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 1e4+10; // just messing with random seeds mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); struct Pt { int x, y; Pt(int a = 0, int b = 0) : x(a), y(b) {} long long operator%(const Pt& p) const { return 1ll * x * p.y - 1ll * y * p.x; } Pt operator-(Pt p) { return Pt(x-p.x, y-p.y); } void operator-=(Pt p) { x -= p.x, y -= p.y; } bool operator==(Pt p) const { return x == p.x && y == p.y; } }; bool half(Pt p) { return p.y < 0 || (p.y == 0 && p.x < 0); } bool operator<(const Pt& a, const Pt& b) { if(half(a) != half(b)) return half(a) < half(b); return a%b > 0; } Pt trees[maxn], camps[maxn]; bool vivo[maxn]; int main() { int W, H; scanf("%d %d", &W, &H); int sx, sy; scanf("%d %d", &sx, &sy); int c; scanf("%d", &c); for(int i = 0, x, y; i < c; i++) scanf("%d %d", &x, &y), camps[i] = Pt(x, y); int n; scanf("%d", &n); for(int i = 0; i < n; i++) { int x, y; scanf("%d %d", &x, &y); trees[i] = Pt(x, y); } // Dou um shuffle pra n ficar com muita gente viva toda hora shuffle(trees, trees+n, rng); memset(vivo, 1, sizeof vivo); vector<pair<Pt, pair<int,int>>> pts; for(int i = 0; i < n; i++) { pts.clear(); pts = {{Pt(sx, sy) - trees[i], {2, 0}}}; for(int j = 0; j < n; j++) if(i != j) pts.push_back({trees[i] - trees[j], {0, 0}}); for(int j = 0; j < c; j++) if(vivo[j]) vivo[j] = 0, pts.push_back({camps[j] - trees[i], {1, j}}); sort(pts.begin(), pts.end()); int pos = -1, sz = (int)pts.size(); for(int j = 0; j < sz; j++) if(pts[j].second.first == 2) pos = j; for(int j = (pos+1)%sz; pts[j].second.first; j = (j+1)%sz) vivo[pts[j].second.second] = 1; for(int j = (pos+sz-1)%sz; pts[j].second.first; j = (j+sz-1)%sz) vivo[pts[j].second.second] = 1; } vector<int> ans; for(int i = 0; i < c; i++) if(vivo[i]) ans.push_back(i+1); printf("%ld\n", ans.size()); for(int x : ans) printf("%d\n", x); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 464 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 3 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 1 ms | 460 KB | Output is correct |
10 | Correct | 4 ms | 460 KB | Output is correct |
11 | Correct | 4 ms | 460 KB | Output is correct |
12 | Correct | 5 ms | 460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 126 ms | 464 KB | Output is correct |
5 | Correct | 27 ms | 460 KB | Output is correct |
6 | Correct | 543 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 896 ms | 560 KB | Output is correct |
2 | Execution timed out | 3051 ms | 844 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |