#include<bits/stdc++.h>
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
using namespace std;
const int N = 6e5;
struct vec{
int x, y;
}a[N+10], b[N+10];
vec operator - (vec a, vec b){
return {a.x-b.x,a.y-b.y};
}
bool operator < (vec a, vec b){
if (a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
int cross(vec a, vec b){
return a.x*b.y-b.x*a.y;
}
int n, m, c, s[N+10];
vector<vec> v;
void convexhull(){
sort(b+1,b+m+1);
//upper
v.push_back(b[1]);
for (int i=2;i<=m;i++){
while(v.size()>=2 && cross(b[i]-v[v.size()-1],v[v.size()-2]-v[v.size()-1])>0) v.pop_back();
v.push_back(b[i]);
}
// lower
for (int i=m-1;i>=2;i--){
while(v.size()>=2 && cross(b[i]-v[v.size()-1],v[v.size()-2]-v[v.size()-1])>0) v.pop_back();
v.push_back(b[i]);
}
}
bool ch(int i, int j){
int j2 = (j+1)%c;
int j3 = (j-1+c)%c;
return (cross(v[j]-a[i],v[j2]-a[i])<=0) && (cross(v[j]-a[i],v[j3]-a[i])<=0);
}
bool check(vec a,vec b,vec c){
return (b.x-a.x) *(c.y-a.y)-(c.x-a.x)*(b.y-a.y)>0;
}
int index(int i){
if (i%(n+1)==0) return n+1;
else return i%(n+1);
}
int get(vec a, vec b, vec c){
if(a.x==b.x&&a.y==b.y) return 0;
return abs(a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y));
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>> n; for (int i=1;i<=n;i++) cin>> a[i].x>>a[i].y;
cin>> m; for (int i=1;i<=m;i++) cin>> b[i].x>>b[i].y;
convexhull();
reverse(a+1,a+n+1);
for (int i=1;i<=2*n;i++) a[n+i] =a[i]; a[3*n+1] = a[1];
for (int i=1;i<=3*n;i++) s[i] = s[i-1]+ cross(a[i],a[i+1]);
int j =0; c = v.size();
for (int i=0;i<c;i++){
if (ch(0,i)){
// cout <<">>"<<i<<" "<<ch(0,i)<<endl;
j = i;
break;
}
}
// for (int i=1;i<=n;i++) cout <<"bg "<<a[i].x<<" "<<a[i].y<<endl;
// for (int i=0;i<c;i++) cout <<"sm "<<v[i].x<<" "<<v[i].y<<endl;
// for (int i=1;i<=n;i++) cout << s[i]<<" "; cout <<endl;
int res = 0;
int far = 2;
int tmp = 0;
for (int i=1;i<=n;i++){
while(!ch(i,j)){
j++; j%=c;
}
while(cross(a[far+1]-a[i],v[j]-a[i])<=0){
tmp += get(a[i],a[far],a[far+1]);
far++;
}
// cout <<">"<<i<<" "<<j<<" "<<far<<endl;
res = max(res, tmp);
tmp -= get(a[i],a[i+1],a[far]);
}
cout <<res<<endl;
}
Compilation message
sir.cpp: In function 'int main()':
sir.cpp:75:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
75 | for (int i=1;i<=2*n;i++) a[n+i] =a[i]; a[3*n+1] = a[1];
| ^~~
sir.cpp:75:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
75 | for (int i=1;i<=2*n;i++) a[n+i] =a[i]; a[3*n+1] = a[1];
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Incorrect |
1 ms |
4524 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
22860 KB |
Output is correct |
2 |
Correct |
120 ms |
22088 KB |
Output is correct |
3 |
Correct |
93 ms |
23752 KB |
Output is correct |
4 |
Correct |
27 ms |
16976 KB |
Output is correct |
5 |
Incorrect |
85 ms |
21056 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |