This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |