#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
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
76 ms |
368 KB |
Output is correct |
5 |
Correct |
15 ms |
340 KB |
Output is correct |
6 |
Correct |
302 ms |
412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
315 ms |
440 KB |
Output is correct |
2 |
Correct |
338 ms |
648 KB |
Output is correct |
3 |
Correct |
439 ms |
596 KB |
Output is correct |
4 |
Correct |
268 ms |
596 KB |
Output is correct |