#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Point {
long long px, py;
};
int shogen(Point p1) {
if (p1.px >= 0 && p1.py >= 0) return 1;
if (p1.px < 0 && p1.py >= 0) return 2;
if (p1.px < 0 && p1.py < 0) return 3;
if (p1.px >= 0 && p1.py < 0) return 4;
}
bool operator<(const Point &a1, const Point &a2) {
int v1 = shogen(a1), v2 = shogen(a2);
if (v1 < v2) return true;
if (v1 > v2) return false;
if (a1.px*a2.py > a1.py*a2.px) return true;
return false;
}
vector<Point>V[2009]; int H, W, sx, sy, N, C, ex[10009], ey[10009];
Point G[2009];
vector<int> solve(long long cx, long long cy) {
vector<int>ans;
for (int i = 1; i <= N; i++) {
int pos1 = lower_bound(V[i].begin(), V[i].end(), Point{ cx - G[i].px, cy - G[i].py }) - V[i].begin();
if (pos1 == N - 1) pos1 = 0;
ans.push_back(pos1);
}
return ans;
}
int main() {
cin >> H >> W >> sx >> sy >> C;
for (int i = 1; i <= C; i++) cin >> ex[i] >> ey[i];
cin >> N;
for (int i = 1; i <= N; i++) cin >> G[i].px >> G[i].py;
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
if (i == j) continue;
V[i].push_back(Point{ G[i].px - G[j].px, G[i].py - G[j].py });
}
sort(V[i].begin(), V[i].end());
}
vector<int>vec = solve(sx, sy);
vector<int>res;
for (int i = 1; i <= C; i++) {
vector<int>vec2 = solve(ex[i], ey[i]);
if (vec == vec2) res.push_back(i);
}
cout << res.size() << endl;
for (int i = 0; i < res.size(); i++) { if (i) cout << " "; cout << res[i]; }
if (res.size() != 0) cout << endl;
return 0;
}
Compilation message
fangorn.cpp: In function 'int main()':
fangorn.cpp:60:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < res.size(); i++) { if (i) cout << " "; cout << res[i]; }
~~^~~~~~~~~~~~
fangorn.cpp: In function 'int shogen(Point)':
fangorn.cpp:15:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
512 KB |
Output is correct |
4 |
Correct |
4 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
896 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
6 ms |
1152 KB |
Output is correct |
11 |
Correct |
6 ms |
1152 KB |
Output is correct |
12 |
Correct |
6 ms |
1152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
150 ms |
16476 KB |
Output is correct |
5 |
Correct |
31 ms |
4224 KB |
Output is correct |
6 |
Correct |
524 ms |
64668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
921 ms |
64676 KB |
Output is correct |
2 |
Execution timed out |
3037 ms |
65016 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |