# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
29610 | 2017-07-20T08:35:37 Z | cdemirer | The Forest of Fangorn (CEOI14_fangorn) | C++14 | 1483 ms | 2304 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> llp; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef vector<vii> vvii; #define pb(x) push_back(x) #define mp(x, y) make_pair(x, y) int W, H; int xg, yg; int C, N; vii camps; vii trees; vii xsort_tree; vi ans; vi getSeq(int a, int b) { vi ret; vector<pair<double, int> > rDif, lDif; vii::iterator it = lower_bound(xsort_tree.begin(), xsort_tree.end(), mp(a, -1)); if (it != xsort_tree.end()) { // fill right part if ((*it).first == a) { if ((*it).second > b) rDif.pb(mp(1e20, (*it).second)); else rDif.pb(mp(-1e20, (*it).second)); it++; } for (; it != xsort_tree.end(); it++) { double tx = trees[ (*it).second ].first; double ty = trees[ (*it).second ].second; double egim = (ty - b) / (tx - a); rDif.pb(mp(egim, (*it).second)); } sort(rDif.begin(), rDif.end()); for (int i = 0; i < rDif.size(); i++) { ret.pb(rDif[i].second); } } it = lower_bound(xsort_tree.begin(), xsort_tree.end(), mp(a, -1)); if (it != xsort_tree.begin()) { // fill left part it--; while (it != xsort_tree.begin()) { double tx = trees[ (*it).second ].first; double ty = trees[ (*it).second ].second; double egim = (ty - b) / (tx - a); lDif.pb(mp(egim, (*it).second)); it--; } double tx = trees[ (*it).second ].first; double ty = trees[ (*it).second ].second; double egim = (ty - b) / (tx - a); lDif.pb(mp(egim, (*it).second)); sort(lDif.begin(), lDif.end()); for (int i = 0; i < lDif.size(); i++) { ret.pb(lDif[i].second); } } return ret; } inline int next(int x) { return (x+1)%N; } bool cyclequal(const vi &a, const vi &b) { int x = a[0]; int p2 = 0; while (b[p2] != x) p2 = next(p2); int cnt = N; int p1 = 0; while (cnt--) { if (a[p1] != b[p2]) return false; p1 = next(p1); p2 = next(p2); } return true; } int main(int argc, char **argv) { //freopen("input", "r", stdin); //freopen("output", "w", stdout); scanf("%d%d", &W, &H); scanf("%d%d", &xg, &yg); scanf("%d", &C); camps.resize(C); for (int i = 0; i < C; i++) { scanf("%d%d", &(camps[i].first), &(camps[i].second)); } scanf("%d", &N); trees.resize(N); for (int i = 0; i < N; i++) { scanf("%d%d", &(trees[i].first), &(trees[i].second)); xsort_tree.pb(mp(trees[i].first, i)); } sort(xsort_tree.begin(), xsort_tree.end()); vi oseq = getSeq(xg, yg); for (int i = 0; i < C; i++) { vi s = getSeq(camps[i].first, camps[i].second); if (cyclequal(oseq, s)) { ans.pb(i+1); } } printf("%d\n", (int)ans.size()); for (int i = 0; i < ans.size(); i++) { printf("%d ", ans[i]); } if (ans.size()>0) puts(""); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2028 KB | Output is correct |
2 | Correct | 0 ms | 2028 KB | Output is correct |
3 | Correct | 0 ms | 2028 KB | Output is correct |
4 | Correct | 0 ms | 2028 KB | Output is correct |
5 | Correct | 0 ms | 2028 KB | Output is correct |
6 | Correct | 0 ms | 2028 KB | Output is correct |
7 | Correct | 0 ms | 2028 KB | Output is correct |
8 | Correct | 0 ms | 2028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2028 KB | Output is correct |
2 | Correct | 0 ms | 2028 KB | Output is correct |
3 | Correct | 0 ms | 2028 KB | Output is correct |
4 | Correct | 0 ms | 2028 KB | Output is correct |
5 | Correct | 0 ms | 2028 KB | Output is correct |
6 | Correct | 0 ms | 2028 KB | Output is correct |
7 | Incorrect | 0 ms | 2028 KB | Output isn't correct |
8 | Correct | 0 ms | 2028 KB | Output is correct |
9 | Correct | 0 ms | 2028 KB | Output is correct |
10 | Correct | 0 ms | 2028 KB | Output is correct |
11 | Correct | 0 ms | 2028 KB | Output is correct |
12 | Correct | 0 ms | 2028 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2028 KB | Output is correct |
2 | Correct | 0 ms | 2028 KB | Output is correct |
3 | Correct | 0 ms | 2028 KB | Output is correct |
4 | Correct | 0 ms | 2028 KB | Output is correct |
5 | Correct | 0 ms | 2028 KB | Output is correct |
6 | Correct | 0 ms | 2168 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 133 ms | 2160 KB | Output is correct |
2 | Correct | 1253 ms | 2304 KB | Output is correct |
3 | Correct | 1483 ms | 2176 KB | Output is correct |
4 | Correct | 1183 ms | 2184 KB | Output is correct |