# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
104948 | | Shtef | SIR (COI15_sir) | C++14 | | 1062 ms | 17720 KiB |
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 <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pll;
#define x first
#define y second
#define mp make_pair
int n, m;
pll a[300005], b[300005];
int ccw(pll x, pll y, pll z){
ll ret = x.x * (y.y - z.y) + y.x * (z.y - x.y) + z.x * (x.y - y.y);
if(ret > 0)
return 1;
if(ret < 0)
return -1;
return 0;
}
bool jedobar(pll x, pll y, int kolko){
for(int i = 0 ; i < m ; ++i){
if(ccw(x, y, b[i]) != kolko)
return 0;
}
return 1;
}
ll povrsina(vector <pll> pts){
if((int)pts.size() < 3)
return 0LL;
ll ret = 0;
for(int i = 0 ; i < (int)pts.size() ; ++i){
ret += (pts[i].x * pts[(i + 1) % ((int)pts.size())].y - pts[(i + 1) % ((int)pts.size())].x * pts[i].y);
}
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0 ; i < n ; ++i){
cin >> a[i].x >> a[i].y;
}
cin >> m;
for(int i = 0 ; i < m ; ++i){
cin >> b[i].x >> b[i].y;
}
int l = 1, r = 1;
ll sol = 0;
for(int i = 0 ; i < n ; ++i){
if(i == l)
l++;
if(i == r)
r++;
while(!jedobar(a[i], a[l], -1)){
l = (l + 1) % n;
}
while(jedobar(a[i], a[r], 1)){
r = (r + 1) % n;
}
r = (r - 1 + n) % n;
vector <pll> v;
for(int j = l ; j != i ; j = (j + 1) % n){
v.push_back(a[j]);
//cout << j << ' ';
}
v.push_back(a[i]);
sol = max(sol, povrsina(v));
//cout << i << " : : : " << sol << " - ";
v.clear();
for(int j = i ; j != r ; j = (j + 1) % n){
v.push_back(a[j]);
//cout << j << ' ';
}
v.push_back(a[r]);
//cout << r << endl;
sol = max(sol, povrsina(v));
v.clear();
//cout << sol << endl;
//cout << i << "-" << l << " : " << r << endl;
}
cout << sol << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |