# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
104948 |
2019-04-09T23:01:57 Z |
Shtef |
SIR (COI15_sir) |
C++14 |
|
1000 ms |
17720 KB |
#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 |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
384 KB |
Output is correct |
2 |
Correct |
15 ms |
512 KB |
Output is correct |
3 |
Correct |
170 ms |
732 KB |
Output is correct |
4 |
Correct |
130 ms |
512 KB |
Output is correct |
5 |
Correct |
13 ms |
520 KB |
Output is correct |
6 |
Correct |
245 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1062 ms |
17720 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |