#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<ll, ll>
#define f first
#define s second
pi operator-(pi x, pi y){
return {x.f - y.f, x.s - y.s};
}
const int maxn = 10000;
int n, m, w, h;
pi s;
pi a[maxn], b[maxn];
int ans[maxn];
bool cp(pi x, pi y){
return x.f * y.s < x.s * y.f;
}
pi af(pi x){
return {(2 * (x.s > 0) - 1) * (abs(x.f) - x.f + abs(x.s)), abs(x.f) + abs(x.s)};
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> w >> h >> s.f >> s.s >> m;
for(int i = 0; i < m; i++){
cin >> b[i].f >> b[i].s;
ans[i] = 1;
}
cin >> n;
for(int i = 0; i < n; i++) cin >> a[i].f >> a[i].s;
int ret = m;
for(int i = 0; i < n; i++){
pi p = af(s - a[i]), pa = {3, 1}, pb = {-3, 1}, pc = {3, 1}, pd = {-3, 1}, px;
for(int j = 0; j < n; j++){
if(i == j) continue;
px = af(a[i] - a[j]);
if(cp(p, px) && cp(px, pa)) pa = px;
else if(cp(px, p) && cp(pb, px)) pb = px;
if(cp(px, pc)) pc = px;
if(cp(pd, px)) pd = px;
}
for(int j = 0; j < m; j++){
px = af(b[j] - a[i]);
ret -= (ans[j] - (ans[j] &= pa.f == 3 ? cp(pb, px) || cp(px, pc): pb.f == -3 ? cp(pd, px) || cp(px, pa) : cp(pb, px) && cp(px, pa)));
}
}
cout << ret << endl;
for(int i = 0; i < m; i++){
if(ans[i]) cout << i + 1;
if(--ret) cout << " ";
}
cout << endl;
return 0;
}
Compilation message
fangorn.cpp: In function 'int main()':
fangorn.cpp:57:35: warning: operation on 'ans[j]' may be undefined [-Wsequence-point]
ret -= (ans[j] - (ans[j] &= pa.f == 3 ? cp(pb, px) || cp(px, pc): pb.f == -3 ? cp(pd, px) || cp(px, pa) : cp(pb, px) && cp(px, pa)));
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |