# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
234640 |
2020-05-24T23:10:59 Z |
knon0501 |
None (KOI18_footprint) |
C++14 |
|
22 ms |
760 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
typedef pair<ll,ll> pp;
pp a[3005];
int dp[3005];
pp p[3005];
int ccw(pp q,pp w,pp e){
ll s=(w.x-q.x)*(e.y-w.y)-(w.y-q.y)*(e.x-w.x);
if(s>0)return 1;
if(s==0)return 0;
if(s<0)return -1;
}
int n;
ll dist(pp q,pp w){
return (q.x-w.x)*(q.x-w.x)+(q.y-w.y)*(q.y-w.y);
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n;
int i;
int k=1;
for(i=1 ; i<=n ; i++){
cin>>a[i].x>>a[i].y;
if(a[i].y<a[k].y)k=i;
}
swap(a[k],a[1]);
sort(a+2,a+n+1,[&](pp q,pp w){ll s=ccw(a[1],q,w);
if(s==0)return dist(a[1],q)<dist(a[1],w);
else return s>0;});
// for(i=1 ; i<=n ; i++)cout<<a[i].x<<" "<<a[i].y<<endl;
k=0;
for(i=2 ; i<=n ; i++)dp[i]=1;
for(i=2 ; i<=n ; i++){
int t=i+1;
if(dp[i]>dp[k])k=i;
for(int j=i+2 ; j<=n ; j++){
if(ccw(a[1],a[t],a[j])!=0 && ccw(a[1],a[t],a[i])!=0 && ccw(a[i],a[t],a[j])<0){
if(dp[i]+1>dp[j]){
dp[j]=dp[i]+1;
p[j]={i,t};
}
}
else if(ccw(a[i],a[t],a[j])>0)t=j;
}
}
if(dp[k]<=1){
cout<<0;
return 0;
}
vector<pp> b;
cout<<2*dp[k]<<"\n";
cout<<a[1].x<<" "<<a[1].y<<"\n";
while(k>0){
b.push_back(a[k]);
if(p[k].second>0)
b.push_back(a[p[k].second]);
k=p[k].first;
}
reverse(b.begin(),b.end());
for(auto i: b)cout<<i.x<<" "<<i.y<<"\n";
return 0;
}
Compilation message
footprint.cpp: In function 'int ccw(pp, pp, pp)':
footprint.cpp:15:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
640 KB |
Output is correct |
2 |
Correct |
22 ms |
640 KB |
Output is correct |
3 |
Correct |
20 ms |
640 KB |
Output is correct |
4 |
Correct |
20 ms |
640 KB |
Output is correct |
5 |
Correct |
20 ms |
640 KB |
Output is correct |
6 |
Correct |
20 ms |
640 KB |
Output is correct |
7 |
Correct |
20 ms |
640 KB |
Output is correct |
8 |
Correct |
20 ms |
640 KB |
Output is correct |
9 |
Correct |
22 ms |
640 KB |
Output is correct |
10 |
Correct |
20 ms |
640 KB |
Output is correct |
11 |
Correct |
20 ms |
640 KB |
Output is correct |
12 |
Correct |
21 ms |
640 KB |
Output is correct |
13 |
Correct |
21 ms |
640 KB |
Output is correct |
14 |
Correct |
20 ms |
640 KB |
Output is correct |
15 |
Correct |
20 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
640 KB |
Output is correct |
2 |
Correct |
22 ms |
640 KB |
Output is correct |
3 |
Correct |
20 ms |
640 KB |
Output is correct |
4 |
Correct |
20 ms |
640 KB |
Output is correct |
5 |
Correct |
20 ms |
640 KB |
Output is correct |
6 |
Correct |
20 ms |
640 KB |
Output is correct |
7 |
Correct |
20 ms |
640 KB |
Output is correct |
8 |
Correct |
20 ms |
640 KB |
Output is correct |
9 |
Correct |
22 ms |
640 KB |
Output is correct |
10 |
Correct |
20 ms |
640 KB |
Output is correct |
11 |
Correct |
20 ms |
640 KB |
Output is correct |
12 |
Correct |
21 ms |
640 KB |
Output is correct |
13 |
Correct |
21 ms |
640 KB |
Output is correct |
14 |
Correct |
20 ms |
640 KB |
Output is correct |
15 |
Correct |
20 ms |
760 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |