# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
932587 |
2024-02-23T19:24:25 Z |
tminh_hk20 |
SIR (COI15_sir) |
C++14 |
|
297 ms |
41428 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
const int N=6e5+5;
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>=1;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]);
}
if (v.size()>1) v.pop_back();
}
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));
}
vec luu[N];
int id;
signed main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>luu[i].x>>luu[i].y;
}
for(int i=n-1;i>=0;i--){
a[i]=luu[n-1-i];
}
// for (int i=0;i<n;i++) cout <<">"<< a[i].x<<" "<<a[i].y<<endl;
for (int i=1;i<=n;i++) a[n-1+i] = a[i-1];
cin>>m;
for(int i=1;i<=m;i++){
cin>>b[i].x>>b[i].y;
}
convexhull();
int sz=v.size();
// cout <<"baoloi"<<endl;
// for(vec i:v){
// cout<<i.x<<" "<<i.y<<endl;
// }
// cout <<endl;
int r=1;
int res=0;
int ans=-1e18;
for(int i=0;i<sz;i++){
if(cross(v[id]-a[0],v[i]-a[0])<=0) id=i;
}
for(int i=0;i<n;i++){
while(!(cross(v[id]-a[i],v[(id+1)%sz]-a[i])<=0)){
id++;
id%=sz;
}
//cout<<i<<" "<<baoloi[id].x<<" "<<baoloi[id].y<<endl;
while(cross(a[r+1]-a[i],v[id]-a[i])<0){
//congdientich
res+=get(a[i],a[r],a[r+1]);
r++;
}
// cout <<">"<<i<<" "<<r<<endl;
ans=max(ans,res);
res-=get(a[i],a[i+1],a[r]);
}
cout<<ans;
}
//>1 4
//>2 4
//>3 0
//>4 1
//>5 3
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
4 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
3 ms |
6600 KB |
Output is correct |
6 |
Correct |
5 ms |
6636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
297 ms |
25324 KB |
Output is correct |
2 |
Correct |
285 ms |
24304 KB |
Output is correct |
3 |
Correct |
250 ms |
25040 KB |
Output is correct |
4 |
Correct |
85 ms |
14936 KB |
Output is correct |
5 |
Correct |
229 ms |
19140 KB |
Output is correct |
6 |
Correct |
255 ms |
41428 KB |
Output is correct |