# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
932110 |
2024-02-23T02:51:25 Z |
vjudge1 |
SIR (COI15_sir) |
C++17 |
|
310 ms |
33428 KB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
int N, M, total=0, vis=0;
vector<pair<int, int> > bigger;
vector<pair<int, int> > smaller;
vector<pair<int, int> > p;
int bell=1, ans=0;
bool check(pair<int, int> a, pair<int, int> b, pair<int, int> c){
return ((b.first-a.first)*(c.second-a.second)-(c.first-a.first)*(b.second-a.second))>0;
}
bool chack(pair<int, int> a, pair<int, int> b, pair<int, int> c){
return ((b.first-a.first)*(c.second-a.second)-(c.first-a.first)*(b.second-a.second))<=0;
}
int get(pair<int, int> a, pair<int, int> b, pair<int, int> c){
return abs(a.first*(b.second-c.second)+b.first*(c.second-a.second)+c.first*(a.second-b.second));
}
bool trapp(pair<int, int> a, int ind){
int x=ind, y;
if(ind==smaller.size()-1){
y=0;
}else{
y=x+1;
}
return chack(a, smaller[x], smaller[y]);
}
bool troll(pair<int, int> a, int ind){
int x=ind, y;
if(ind==0){
y=smaller.size()-1;
}else{
y=x-1;
}
return chack(a, smaller[x], smaller[y]);
}
void solve(){
sort(p.begin(), p.end());
smaller.push_back(p[0]);
for(int i=1; i<M; i++){
while(smaller.size()>=2 && check(smaller[smaller.size()-2], smaller[smaller.size()-1], p[i])){
smaller.pop_back();
}
smaller.push_back(p[i]);
}
for(int i=M-2; i>=0; i--){
while(smaller.size()>=2 && check(smaller[smaller.size()-2], smaller[smaller.size()-1], p[i])){
smaller.pop_back();
}
smaller.push_back(p[i]);
}
if(M>1) smaller.pop_back();
}
signed main(){
cin>>N;
for(int i=1; i<=N; i++){
int x, y; cin>>x>>y; bigger.push_back({x, y});
}
reverse(bigger.begin(), bigger.end());
cin>>M;
for(int i=1; i<=M; i++){
int x, y; cin>>x>>y; p.push_back({x, y});
}
solve(); M=smaller.size();
for(int i=0; i<M; i++){
if(trapp(bigger[0], i) && troll(bigger[0], i)){
vis=i; break;
}
}
for(int i=0; i<bigger.size(); i++){
while(!(trapp(bigger[i], vis) && troll(bigger[i], vis))){
vis++; vis%=smaller.size();
}
if(i){
int x=i-1;
if(x==-1) x=N-1;
int y=bell-1;
if(y==-1) y=N-1;
ans-=get(bigger[x], bigger[i], bigger[y]);
}
for(bell; check(bigger[i], smaller[vis], bigger[bell]); bell++, bell%=N){
int x=bell-1;
if(x==-1) x=N-1;
ans+=get(bigger[i], bigger[x], bigger[bell]);
}
total=max(total, ans);
}
cout<<total;
}
Compilation message
sir.cpp: In function 'bool trapp(std::pair<long long int, long long int>, long long int)':
sir.cpp:20:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | if(ind==smaller.size()-1){
| ~~~^~~~~~~~~~~~~~~~~~
sir.cpp: In function 'int main()':
sir.cpp:69:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(int i=0; i<bigger.size(); i++){
| ~^~~~~~~~~~~~~~
sir.cpp:80:7: warning: statement has no effect [-Wunused-value]
80 | for(bell; check(bigger[i], smaller[vis], bigger[bell]); bell++, bell%=N){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
604 KB |
Output is correct |
6 |
Correct |
3 ms |
704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
310 ms |
13080 KB |
Output is correct |
2 |
Correct |
298 ms |
14612 KB |
Output is correct |
3 |
Correct |
253 ms |
13968 KB |
Output is correct |
4 |
Correct |
89 ms |
5568 KB |
Output is correct |
5 |
Correct |
246 ms |
17644 KB |
Output is correct |
6 |
Correct |
251 ms |
33428 KB |
Output is correct |