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 <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)
using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;
//Note to self: Check for overflow
int cx[10004],cy[10004];
bool ima[10004];
int x[10004],y[10004];
bool gore(pii a)
{
return a.yy>0 || (a.yy==0 && a.xx>0);
}
struct bogosort
{
bool operator() (pii a, pii b)
{
if (gore(a) && !gore(b)) return true;
if (!gore(a) && gore(b)) return false;
return (li)a.xx*b.yy - (li)a.yy*b.xx > 0;
}
};
bool unutar(int a, int b, int c, int d, int e, int f)
{
if ((li)a*d - (li)b*c < 0) swap(a,c),swap(b,d);
if ((li)a*f - (li)b*e > 0 && (li)e*d - (li)f*c > 0) return true;
return false;
}
int main()
{
FAST;
int w,h;
cin>>w>>h;
int px,py;
cin>>px>>py;
int m; cin>>m;
ff(i,0,m) cin>>cx[i]>>cy[i];
ff(i,0,m) ima[i]=true;
int n; cin>>n;
ff(i,0,n) cin>>x[i]>>y[i];
ff(i,0,n)
{
vector<pii> veki;
ff(j,0,n) if (i!=j) veki.pb({x[i]-x[j],y[i]-y[j]});
int tx=px-x[i],ty=py-y[i];
veki.pb({tx,ty}); //znamo da je svaki smer unique
sort(all(veki),bogosort());
pii L,R;
ff(j,0,n) if (veki[j]==make_pair(tx,ty))
{
L=veki[(j+n-1)%n];
R=veki[(j+1)%n];
break;
}
/*cout<<i<<": ";
cout<<"("<<L.xx<<","<<L.yy<<") i ("<<R.xx<<","<<R.yy<<")"<<endl;
cout<<tx<<" "<<ty<<endl;*/
ff(j,0,m) if (unutar(L.xx,L.yy,R.xx,R.yy,tx,ty) != unutar(L.xx,L.yy,R.xx,R.yy,cx[j]-x[i],cy[j]-y[i])) /*cout<<"block "<<cx[j]-x[i]<<","<<cy[j]-y[i]<<endl,*/ima[j]=false;
}
vector<int> ans;
ff(i,0,m) if (ima[i]) ans.pb(i+1);
cout<<(int)ans.size()<<"\n";
for (auto it : ans) cout<<it<<" ";
}
//Note to self: Check for overflow
/*
5 4
2 3
4
0 0
5 4
1 2
2 4
3
1 1
3 1
1 3
*/
# | 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... |