# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
63153 |
2018-08-01T01:19:19 Z |
khsoo01 |
None (KOI18_footprint) |
C++11 |
|
1911 ms |
84672 KB |
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 3005, inf = 1e9;
int n;
pii a[N], dt[N][N][2], piv;
vector<int> ans;
long long ccw (pii &A, pii &B, pii &C) {
return (1ll*A.X*B.Y+1ll*B.X*C.Y+1ll*C.X*A.Y) - (1ll*A.Y*B.X+1ll*B.Y*C.X+1ll*C.Y*A.X);
}
bool cmp (pii &A, pii &B) {
return ccw(piv, A, B) > 0;
}
bool cmp2 (int A, int B) {
return ccw(piv, a[A], a[B]) > 0;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) {
scanf("%d%d",&a[i].X,&a[i].Y);
if(a[i].Y < a[1].Y) swap(a[i], a[1]);
}
piv = a[1];
sort(a+2, a+1+n, cmp);
for(int i=1;i<=n;i++) {
dt[1][i][0] = {1, 0};
}
for(int k=2;k<=n;k++) {
vector<int> A, B;
A.push_back(1);
for(int i=2;i<k;i++) {
if(ccw(a[1], a[k], a[i]) != 0) A.push_back(i);
}
for(int i=k+1;i<=n;i++) {
if(ccw(a[1], a[k], a[i]) != 0) B.push_back(i);
}
piv = a[k];
sort(A.begin(), A.end(), cmp2);
sort(B.begin(), B.end(), cmp2);
int j = 0;
pii V = {-inf, -inf};
for(int i=0;i<=(int)A.size();i++) {
int T = (i < (int)A.size() ? A[i] : k);
while(j<(int)B.size() && ccw(a[T], a[k], a[B[j]]) <= 0) {
dt[k][B[j]][1] = max(dt[k][B[j]][1], V);
j++;
}
V = max(V, {dt[T][k][0].X+1, T});
}
j = (int)B.size()-1;
V = {-inf, -inf};
for(int i=(int)A.size()-1;i>=-1;i--) {
int T = (i >= 0 ? A[i] : k);
while(j >= 0 && ccw(a[T], a[k], a[B[j]]) >= 0) {
dt[k][B[j]][0] = max(dt[k][B[j]][0], V);
j--;
}
V = max(V, {dt[T][k][1].X+1, T});
}
}
int V = 0, A, B, C = 0;
for(int i=1;i<=n;i++) {
for(int j=1;j<=n;j++) {
if(V < dt[i][j][0].X) {
V = dt[i][j][0].X;
A = i;
B = j;
}
}
}
if(V == 1) {
puts("0");
return 0;
}
for(int i=0;i<V;i++) {
ans.push_back(B);
int T = A;
A = dt[A][B][C].Y;
B = T;
C ^= 1;
}
ans.push_back(1);
reverse(ans.begin(), ans.end());
printf("%d\n",(int)ans.size());
for(auto &T : ans) {
printf("%d %d\n", a[T].X, a[T].Y);
}
}
Compilation message
footprint.cpp: In function 'int main()':
footprint.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
footprint.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&a[i].X,&a[i].Y);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
footprint.cpp:88:5: warning: 'A' may be used uninitialized in this function [-Wmaybe-uninitialized]
A = dt[A][B][C].Y;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1393 ms |
70052 KB |
Output is correct |
2 |
Correct |
1426 ms |
72624 KB |
Output is correct |
3 |
Correct |
1449 ms |
72624 KB |
Output is correct |
4 |
Correct |
1346 ms |
72888 KB |
Output is correct |
5 |
Correct |
1393 ms |
72888 KB |
Output is correct |
6 |
Correct |
1487 ms |
73168 KB |
Output is correct |
7 |
Correct |
1402 ms |
73168 KB |
Output is correct |
8 |
Correct |
1406 ms |
73484 KB |
Output is correct |
9 |
Correct |
1496 ms |
73716 KB |
Output is correct |
10 |
Correct |
1544 ms |
73716 KB |
Output is correct |
11 |
Correct |
1442 ms |
73716 KB |
Output is correct |
12 |
Correct |
1603 ms |
74140 KB |
Output is correct |
13 |
Correct |
1504 ms |
75540 KB |
Output is correct |
14 |
Correct |
1550 ms |
75540 KB |
Output is correct |
15 |
Correct |
1444 ms |
75540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
75540 KB |
Output is correct |
2 |
Correct |
2 ms |
75540 KB |
Output is correct |
3 |
Correct |
2 ms |
75540 KB |
Output is correct |
4 |
Correct |
3 ms |
75540 KB |
Output is correct |
5 |
Correct |
2 ms |
75540 KB |
Output is correct |
6 |
Correct |
3 ms |
75540 KB |
Output is correct |
7 |
Correct |
3 ms |
75540 KB |
Output is correct |
8 |
Correct |
3 ms |
75540 KB |
Output is correct |
9 |
Correct |
2 ms |
75540 KB |
Output is correct |
10 |
Correct |
2 ms |
75540 KB |
Output is correct |
11 |
Correct |
4 ms |
75540 KB |
Output is correct |
12 |
Correct |
3 ms |
75540 KB |
Output is correct |
13 |
Correct |
3 ms |
75540 KB |
Output is correct |
14 |
Correct |
2 ms |
75540 KB |
Output is correct |
15 |
Correct |
3 ms |
75540 KB |
Output is correct |
16 |
Correct |
3 ms |
75540 KB |
Output is correct |
17 |
Correct |
2 ms |
75540 KB |
Output is correct |
18 |
Correct |
3 ms |
75540 KB |
Output is correct |
19 |
Correct |
2 ms |
75540 KB |
Output is correct |
20 |
Correct |
3 ms |
75540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
75540 KB |
Output is correct |
2 |
Correct |
2 ms |
75540 KB |
Output is correct |
3 |
Correct |
2 ms |
75540 KB |
Output is correct |
4 |
Correct |
3 ms |
75540 KB |
Output is correct |
5 |
Correct |
2 ms |
75540 KB |
Output is correct |
6 |
Correct |
3 ms |
75540 KB |
Output is correct |
7 |
Correct |
3 ms |
75540 KB |
Output is correct |
8 |
Correct |
3 ms |
75540 KB |
Output is correct |
9 |
Correct |
2 ms |
75540 KB |
Output is correct |
10 |
Correct |
2 ms |
75540 KB |
Output is correct |
11 |
Correct |
4 ms |
75540 KB |
Output is correct |
12 |
Correct |
3 ms |
75540 KB |
Output is correct |
13 |
Correct |
3 ms |
75540 KB |
Output is correct |
14 |
Correct |
2 ms |
75540 KB |
Output is correct |
15 |
Correct |
3 ms |
75540 KB |
Output is correct |
16 |
Correct |
3 ms |
75540 KB |
Output is correct |
17 |
Correct |
2 ms |
75540 KB |
Output is correct |
18 |
Correct |
3 ms |
75540 KB |
Output is correct |
19 |
Correct |
2 ms |
75540 KB |
Output is correct |
20 |
Correct |
3 ms |
75540 KB |
Output is correct |
21 |
Correct |
20 ms |
75540 KB |
Output is correct |
22 |
Correct |
15 ms |
75540 KB |
Output is correct |
23 |
Correct |
15 ms |
75540 KB |
Output is correct |
24 |
Correct |
23 ms |
75540 KB |
Output is correct |
25 |
Correct |
18 ms |
75540 KB |
Output is correct |
26 |
Correct |
17 ms |
75540 KB |
Output is correct |
27 |
Correct |
17 ms |
75540 KB |
Output is correct |
28 |
Correct |
17 ms |
75540 KB |
Output is correct |
29 |
Correct |
16 ms |
75540 KB |
Output is correct |
30 |
Correct |
18 ms |
75540 KB |
Output is correct |
31 |
Correct |
21 ms |
75540 KB |
Output is correct |
32 |
Correct |
21 ms |
75540 KB |
Output is correct |
33 |
Correct |
12 ms |
75540 KB |
Output is correct |
34 |
Correct |
13 ms |
75540 KB |
Output is correct |
35 |
Correct |
15 ms |
75540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1393 ms |
70052 KB |
Output is correct |
2 |
Correct |
1426 ms |
72624 KB |
Output is correct |
3 |
Correct |
1449 ms |
72624 KB |
Output is correct |
4 |
Correct |
1346 ms |
72888 KB |
Output is correct |
5 |
Correct |
1393 ms |
72888 KB |
Output is correct |
6 |
Correct |
1487 ms |
73168 KB |
Output is correct |
7 |
Correct |
1402 ms |
73168 KB |
Output is correct |
8 |
Correct |
1406 ms |
73484 KB |
Output is correct |
9 |
Correct |
1496 ms |
73716 KB |
Output is correct |
10 |
Correct |
1544 ms |
73716 KB |
Output is correct |
11 |
Correct |
1442 ms |
73716 KB |
Output is correct |
12 |
Correct |
1603 ms |
74140 KB |
Output is correct |
13 |
Correct |
1504 ms |
75540 KB |
Output is correct |
14 |
Correct |
1550 ms |
75540 KB |
Output is correct |
15 |
Correct |
1444 ms |
75540 KB |
Output is correct |
16 |
Correct |
2 ms |
75540 KB |
Output is correct |
17 |
Correct |
2 ms |
75540 KB |
Output is correct |
18 |
Correct |
2 ms |
75540 KB |
Output is correct |
19 |
Correct |
3 ms |
75540 KB |
Output is correct |
20 |
Correct |
2 ms |
75540 KB |
Output is correct |
21 |
Correct |
3 ms |
75540 KB |
Output is correct |
22 |
Correct |
3 ms |
75540 KB |
Output is correct |
23 |
Correct |
3 ms |
75540 KB |
Output is correct |
24 |
Correct |
2 ms |
75540 KB |
Output is correct |
25 |
Correct |
2 ms |
75540 KB |
Output is correct |
26 |
Correct |
4 ms |
75540 KB |
Output is correct |
27 |
Correct |
3 ms |
75540 KB |
Output is correct |
28 |
Correct |
3 ms |
75540 KB |
Output is correct |
29 |
Correct |
2 ms |
75540 KB |
Output is correct |
30 |
Correct |
3 ms |
75540 KB |
Output is correct |
31 |
Correct |
3 ms |
75540 KB |
Output is correct |
32 |
Correct |
2 ms |
75540 KB |
Output is correct |
33 |
Correct |
3 ms |
75540 KB |
Output is correct |
34 |
Correct |
2 ms |
75540 KB |
Output is correct |
35 |
Correct |
3 ms |
75540 KB |
Output is correct |
36 |
Correct |
20 ms |
75540 KB |
Output is correct |
37 |
Correct |
15 ms |
75540 KB |
Output is correct |
38 |
Correct |
15 ms |
75540 KB |
Output is correct |
39 |
Correct |
23 ms |
75540 KB |
Output is correct |
40 |
Correct |
18 ms |
75540 KB |
Output is correct |
41 |
Correct |
17 ms |
75540 KB |
Output is correct |
42 |
Correct |
17 ms |
75540 KB |
Output is correct |
43 |
Correct |
17 ms |
75540 KB |
Output is correct |
44 |
Correct |
16 ms |
75540 KB |
Output is correct |
45 |
Correct |
18 ms |
75540 KB |
Output is correct |
46 |
Correct |
21 ms |
75540 KB |
Output is correct |
47 |
Correct |
21 ms |
75540 KB |
Output is correct |
48 |
Correct |
12 ms |
75540 KB |
Output is correct |
49 |
Correct |
13 ms |
75540 KB |
Output is correct |
50 |
Correct |
15 ms |
75540 KB |
Output is correct |
51 |
Correct |
1470 ms |
75540 KB |
Output is correct |
52 |
Correct |
1521 ms |
75540 KB |
Output is correct |
53 |
Correct |
1584 ms |
75956 KB |
Output is correct |
54 |
Correct |
1697 ms |
84252 KB |
Output is correct |
55 |
Correct |
1761 ms |
84252 KB |
Output is correct |
56 |
Correct |
1911 ms |
84340 KB |
Output is correct |
57 |
Correct |
1851 ms |
84340 KB |
Output is correct |
58 |
Correct |
1775 ms |
84340 KB |
Output is correct |
59 |
Correct |
1820 ms |
84356 KB |
Output is correct |
60 |
Correct |
1875 ms |
84592 KB |
Output is correct |
61 |
Correct |
1778 ms |
84592 KB |
Output is correct |
62 |
Correct |
1812 ms |
84652 KB |
Output is correct |
63 |
Correct |
1057 ms |
84652 KB |
Output is correct |
64 |
Correct |
1189 ms |
84652 KB |
Output is correct |
65 |
Correct |
1093 ms |
84652 KB |
Output is correct |
66 |
Correct |
1448 ms |
84652 KB |
Output is correct |
67 |
Correct |
1417 ms |
84652 KB |
Output is correct |
68 |
Correct |
1441 ms |
84672 KB |
Output is correct |