#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL ccw(LL a, LL b, LL c, LL d){
LL rv = a * d - b * c;
return rv ? rv > 0 ? 1 : -1 : 0;
}
LL N;
struct data{
LL x, y, mx, my;
bool operator<(const data&r)const{
return ccw(mx, my, r.mx, r.my) == 1;
}
}arr[3004];
LL d[3004][3], from[3004][3];
void out(LL A, LL B, LL dep){
if(A == 1){
printf("%lld\n%lld %lld\n", dep, arr[A].x, arr[A].y);
return;
}
out(from[A][B], 1 - B, dep + 1);
printf("%lld %lld\n", arr[A].x, arr[A].y);
}
int main(){
scanf("%lld", &N);
LL low = (LL)1e9, num;
for(LL i = 1; i <= N; ++i){
scanf("%lld %lld", &arr[i].x, &arr[i].y);
if(arr[i].y < low){
low = arr[i].y, num = i;
}
}
swap(arr[1], arr[num]);
for(LL i = 1; i <= N; ++i){
arr[i].mx = arr[i].x - arr[1].x;
arr[i].my = arr[i].y - arr[1].y;
}
sort(arr + 2, arr + N + 1);
for(LL i = 2; i <= N; ++i){
d[i][1] = from[i][1] = 1;
}
for(LL i = 3; i <= N; ++i){
for(LL k = 0; k < 2; ++k){
for(LL j = 2; j < i; ++j){
if(ccw(arr[i].mx, arr[i].my, arr[j].mx, arr[j].my) == 0){
continue;
}
if(from[j][1 - k] && ccw(arr[i].x - arr[from[j][1 - k]].x, arr[i].y - arr[from[j][1 - k]].y,
arr[j].x - arr[from[j][1 - k]].x, arr[j].y - arr[from[j][1 - k]].y) == k - (k == 0)){
if(d[j][1 - k] + 1 > d[i][k] || !from[i][k] || (d[j][1 - k] + 1 == d[i][k] &&
ccw(arr[from[i][k]].x - arr[i].x, arr[from[i][k]].y - arr[i].y,
arr[j].x - arr[i].x, arr[j].y - arr[i].y) != k - (k == 0))){
d[i][k] = d[j][1 - k] + 1;
from[i][k] = j;
}
}
}
}
}
LL pos, big = -1;
for(LL i = 2; i <= N; ++i){
if(d[i][1] > big){
big = d[i][1], pos = i;
}
}
if(big < 3){
puts("0"); return 0;
}
out(pos, 1, 1);
return 0;
}
Compilation message
footprint.cpp: In function 'int main()':
footprint.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
31 | scanf("%lld", &N);
| ~~~~~^~~~~~~~~~~~
footprint.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
34 | scanf("%lld %lld", &arr[i].x, &arr[i].y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
footprint.cpp:32:23: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
32 | LL low = (LL)1e9, num;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
748 KB |
Output is correct |
2 |
Correct |
73 ms |
748 KB |
Output is correct |
3 |
Correct |
72 ms |
748 KB |
Output is correct |
4 |
Correct |
75 ms |
748 KB |
Output is correct |
5 |
Correct |
74 ms |
748 KB |
Output is correct |
6 |
Correct |
75 ms |
748 KB |
Output is correct |
7 |
Correct |
74 ms |
748 KB |
Output is correct |
8 |
Correct |
82 ms |
652 KB |
Output is correct |
9 |
Correct |
74 ms |
748 KB |
Output is correct |
10 |
Correct |
73 ms |
748 KB |
Output is correct |
11 |
Correct |
74 ms |
748 KB |
Output is correct |
12 |
Correct |
74 ms |
748 KB |
Output is correct |
13 |
Correct |
78 ms |
656 KB |
Output is correct |
14 |
Correct |
75 ms |
748 KB |
Output is correct |
15 |
Correct |
74 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
236 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
236 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
2 ms |
364 KB |
Output is correct |
25 |
Correct |
2 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
2 ms |
364 KB |
Output is correct |
28 |
Correct |
2 ms |
364 KB |
Output is correct |
29 |
Correct |
2 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
2 ms |
364 KB |
Output is correct |
32 |
Correct |
2 ms |
364 KB |
Output is correct |
33 |
Correct |
1 ms |
364 KB |
Output is correct |
34 |
Correct |
2 ms |
364 KB |
Output is correct |
35 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
748 KB |
Output is correct |
2 |
Correct |
73 ms |
748 KB |
Output is correct |
3 |
Correct |
72 ms |
748 KB |
Output is correct |
4 |
Correct |
75 ms |
748 KB |
Output is correct |
5 |
Correct |
74 ms |
748 KB |
Output is correct |
6 |
Correct |
75 ms |
748 KB |
Output is correct |
7 |
Correct |
74 ms |
748 KB |
Output is correct |
8 |
Correct |
82 ms |
652 KB |
Output is correct |
9 |
Correct |
74 ms |
748 KB |
Output is correct |
10 |
Correct |
73 ms |
748 KB |
Output is correct |
11 |
Correct |
74 ms |
748 KB |
Output is correct |
12 |
Correct |
74 ms |
748 KB |
Output is correct |
13 |
Correct |
78 ms |
656 KB |
Output is correct |
14 |
Correct |
75 ms |
748 KB |
Output is correct |
15 |
Correct |
74 ms |
748 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
236 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
364 KB |
Output is correct |
28 |
Correct |
1 ms |
364 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
33 |
Correct |
1 ms |
364 KB |
Output is correct |
34 |
Correct |
1 ms |
364 KB |
Output is correct |
35 |
Correct |
1 ms |
364 KB |
Output is correct |
36 |
Correct |
1 ms |
364 KB |
Output is correct |
37 |
Correct |
1 ms |
364 KB |
Output is correct |
38 |
Correct |
1 ms |
364 KB |
Output is correct |
39 |
Correct |
2 ms |
364 KB |
Output is correct |
40 |
Correct |
2 ms |
364 KB |
Output is correct |
41 |
Correct |
1 ms |
364 KB |
Output is correct |
42 |
Correct |
2 ms |
364 KB |
Output is correct |
43 |
Correct |
2 ms |
364 KB |
Output is correct |
44 |
Correct |
2 ms |
364 KB |
Output is correct |
45 |
Correct |
2 ms |
364 KB |
Output is correct |
46 |
Correct |
2 ms |
364 KB |
Output is correct |
47 |
Correct |
2 ms |
364 KB |
Output is correct |
48 |
Correct |
1 ms |
364 KB |
Output is correct |
49 |
Correct |
2 ms |
364 KB |
Output is correct |
50 |
Correct |
1 ms |
364 KB |
Output is correct |
51 |
Correct |
79 ms |
748 KB |
Output is correct |
52 |
Correct |
73 ms |
748 KB |
Output is correct |
53 |
Correct |
78 ms |
748 KB |
Output is correct |
54 |
Correct |
102 ms |
748 KB |
Output is correct |
55 |
Correct |
97 ms |
748 KB |
Output is correct |
56 |
Correct |
98 ms |
748 KB |
Output is correct |
57 |
Correct |
115 ms |
748 KB |
Output is correct |
58 |
Correct |
104 ms |
660 KB |
Output is correct |
59 |
Correct |
108 ms |
620 KB |
Output is correct |
60 |
Correct |
99 ms |
620 KB |
Output is correct |
61 |
Correct |
97 ms |
620 KB |
Output is correct |
62 |
Correct |
103 ms |
620 KB |
Output is correct |
63 |
Correct |
69 ms |
620 KB |
Output is correct |
64 |
Correct |
69 ms |
620 KB |
Output is correct |
65 |
Correct |
71 ms |
748 KB |
Output is correct |
66 |
Correct |
64 ms |
620 KB |
Output is correct |
67 |
Correct |
66 ms |
620 KB |
Output is correct |
68 |
Correct |
65 ms |
620 KB |
Output is correct |