#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<n; i++)
using namespace std;
struct pii {
int x, y;
bool operator<(const pii b) const { return y<b.y || (y==b.y && x<b.x); }
pii operator-(const pii b) const { return {x-b.x, y-b.y}; }
};
long cross(pii a, pii b) { return a.x*long(b.y)-a.y*long(b.x); }
long ccw(pii o, pii a, pii b) { return cross(o-a, o-b); }
int main() {
ios_base::sync_with_stdio(false);cin.tie(nullptr);
int N;
cin>>N;
vector<pii> A(N);
for(auto&[x,y]:A) cin>>x>>y;
swap(A[0], *min_element(begin(A), end(A)));
sort(begin(A)+1, end(A), [&](pii x, pii y) { return ccw(A[0], x, y)<0; });
if(N>300) {
cout<<N<<'\n';
reverse(begin(A)+1, end(A));
for(auto[x,y]:A) cout<<x<<' '<<y<<'\n';
return 0;
}
vector<vector<pii>> D1(N, vector<pii>(N)), D2=D1;
int a=0, b=0, c=0;
rep(i, 1, N) D2[0][i]={2, 0};
rep(i, 0, N) rep(j, 0, i) {
if(ccw(A[0], A[j], A[i])==0) continue;
rep(k, 0, j) {
long z=ccw(A[k], A[j], A[i]);
#define maxi(a, b, c) if(a.x<b.x+1) a={b.x+1, c}
if(z<0) maxi(D1[j][i], D2[k][j], k);
if(z>0) maxi(D2[j][i], D1[k][j], k);
}
if(D2[a][b].x<D2[j][i].x) a=j, b=i;
}
if(D2[a][b].x<4) {
cout<<"0\n";
return 0;
}
cout<<D2[a][b].x<<'\n'<<A[0].x<<' '<<A[0].y<<'\n';
do {
cout<<A[b].x<<' '<<A[b].y<<'\n';
b=c++%2 ? D1[a][b].y : D2[a][b].y;
swap(a, b);
} while(b);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
10 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
420 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
380 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
380 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
3 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
420 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
380 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
380 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
3 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
26 ms |
1656 KB |
Output is correct |
22 |
Correct |
27 ms |
1656 KB |
Output is correct |
23 |
Correct |
26 ms |
1528 KB |
Output is correct |
24 |
Correct |
33 ms |
1824 KB |
Output is correct |
25 |
Correct |
33 ms |
1784 KB |
Output is correct |
26 |
Correct |
34 ms |
1824 KB |
Output is correct |
27 |
Correct |
31 ms |
1784 KB |
Output is correct |
28 |
Correct |
31 ms |
1784 KB |
Output is correct |
29 |
Correct |
31 ms |
1784 KB |
Output is correct |
30 |
Correct |
34 ms |
1856 KB |
Output is correct |
31 |
Correct |
44 ms |
1784 KB |
Output is correct |
32 |
Correct |
34 ms |
1784 KB |
Output is correct |
33 |
Correct |
26 ms |
1912 KB |
Output is correct |
34 |
Correct |
26 ms |
1784 KB |
Output is correct |
35 |
Correct |
26 ms |
1784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
10 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
420 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
380 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
380 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
2 ms |
376 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
3 ms |
376 KB |
Output is correct |
35 |
Correct |
2 ms |
376 KB |
Output is correct |
36 |
Correct |
26 ms |
1656 KB |
Output is correct |
37 |
Correct |
27 ms |
1656 KB |
Output is correct |
38 |
Correct |
26 ms |
1528 KB |
Output is correct |
39 |
Correct |
33 ms |
1824 KB |
Output is correct |
40 |
Correct |
33 ms |
1784 KB |
Output is correct |
41 |
Correct |
34 ms |
1824 KB |
Output is correct |
42 |
Correct |
31 ms |
1784 KB |
Output is correct |
43 |
Correct |
31 ms |
1784 KB |
Output is correct |
44 |
Correct |
31 ms |
1784 KB |
Output is correct |
45 |
Correct |
34 ms |
1856 KB |
Output is correct |
46 |
Correct |
44 ms |
1784 KB |
Output is correct |
47 |
Correct |
34 ms |
1784 KB |
Output is correct |
48 |
Correct |
26 ms |
1912 KB |
Output is correct |
49 |
Correct |
26 ms |
1784 KB |
Output is correct |
50 |
Correct |
26 ms |
1784 KB |
Output is correct |
51 |
Correct |
4 ms |
504 KB |
Output is correct |
52 |
Correct |
4 ms |
504 KB |
Output is correct |
53 |
Correct |
4 ms |
504 KB |
Output is correct |
54 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
55 |
Halted |
0 ms |
0 KB |
- |