Submission #364763

#TimeUsernameProblemLanguageResultExecution timeMemory
364763ijxjdjdThe Forest of Fangorn (CEOI14_fangorn)C++14
0 / 100
3016 ms492 KiB
#include <bits/stdc++.h> #define FR(i, N) for (int i = 0; i < int(N); i++) #define all(x) begin(x), end(x) using namespace std; using ll = long long; int N, M; const int MAXN = 2000; const int MAXM = 10000; struct Point { int x, y; void print() { cerr << x << " " << y << endl; } }; Point start; int bad[MAXM]; Point pos[MAXN]; Point cmps[MAXM]; void solve(int n) { FR(i, N) { if (i != n) { pos[i].x -= pos[n].x; pos[i].y -= pos[n].y; } } FR(i, M) { cmps[i].x -= pos[n].x; cmps[i].y -= pos[n].y; } start.x -= pos[n].x; start.y -= pos[n].y; vector<Point> pt; FR(i, N) { if (i != n) { pt.push_back({-pos[i].x, -pos[i].y}); } } auto comp = [](const auto& lhs, const auto& rhs) { if (lhs.x == 0) { if (lhs.y > 0) { return true; } else { return rhs.x < 0; } } if (rhs.x == 0) { if (rhs.y > 0) { return false; } else { return lhs.x >= 0; } } if (lhs.x < 0 && rhs.x > 0) { return false; } if (lhs.x > 0 && rhs.x < 0) { return true; } if (lhs.x > 0) { return lhs.y * rhs.x - lhs.x * rhs.y > 0; } else { return lhs.y * (-rhs.x) - (-lhs.x) * rhs.y < 0; } }; // cout << n << endl; // for (auto& p : pt) { // p.print(); // } sort(all(pt), comp); if (comp(start, pt[0]) || comp(pt[pt.size()-1], start)) { FR(i, M) { if (comp(cmps[i], pt[0]) || comp(pt[pt.size()-1], cmps[i])) { bad[i]++; } } } else { for (int i = 1; i <= pt.size(); i++) { if (comp(start, pt[i])) { FR(j, M) { if (!comp(cmps[j], pt[i-1]) && !comp(cmps[j], pt[i-1])) { bad[j]++; } } } } } FR(i, N) { if (i != n) { pos[i].x += pos[n].x; pos[i].y += pos[n].y; } } FR(i, M) { cmps[i].x += pos[n].x; cmps[i].y += pos[n].y; } start.x += pos[n].x; start.y += pos[n].y; } int main() { cin.tie(0); cin.sync_with_stdio(0); int hg; cin >> hg >> hg; cin >> start.x >> start.y; cin >> M; FR(i, M) { cin >> cmps[i].x >> cmps[i].y; } cin >> N; FR(i, N) { cin >> pos[i].x >> pos[i].y; } FR(i, N) { solve(i); } vector<int> ans; FR(j, M) { if (bad[j] == N) { ans.push_back(j+1); } } cout << ans.size() << '\n'; for (int p :ans){ cout << p << " "; } return 0; }

Compilation message (stderr)

fangorn.cpp: In function 'void solve(int)':
fangorn.cpp:84:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |         for (int i = 1; i <= pt.size(); i++) {
      |                         ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...