Submission #167589

# Submission time Handle Problem Language Result Execution time Memory
167589 2019-12-09T04:16:24 Z cgiosy None (KOI18_footprint) C++17
100 / 100
59 ms 632 KB
#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; });
	vector<pii> D1(N), D2(N);
	int a=0, c=0;
	rep(i, 1, N) D2[i]={2, 0};
	rep(i, 0, N) {
		rep(j, 0, i) {
			if(ccw(A[0], A[j], A[i])==0) continue;
			#define maxi(a, b, c, d) \
				if(ccw(A[b.y], A[j], A[i])*d<0 \
				&& (a.x<b.x+1 || (a.x==b.x+1 && ccw(A[i], A[a.y], A[j])*d<0))) \
					a={b.x+1, c}
			maxi(D1[i], D2[j], j, 1);
			maxi(D2[i], D1[j], j, -1);
		}
		if(D2[a].x<D2[i].x) a=i;
	}
	if(D2[a].x<4) {
		cout<<"0\n";
		return 0;
	}
	cout<<D2[a].x<<'\n'<<A[0].x<<' '<<A[0].y<<'\n';
	do cout<<A[a].x<<' '<<A[a].y<<'\n'; while(a=c++%2 ? D1[a].y : D2[a].y);
}

Compilation message

footprint.cpp: In function 'int main()':
footprint.cpp:40:45: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  do cout<<A[a].x<<' '<<A[a].y<<'\n'; while(a=c++%2 ? D1[a].y : D2[a].y);
                                            ~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 43 ms 504 KB Output is correct
2 Correct 43 ms 504 KB Output is correct
3 Correct 42 ms 532 KB Output is correct
4 Correct 44 ms 504 KB Output is correct
5 Correct 46 ms 508 KB Output is correct
6 Correct 44 ms 504 KB Output is correct
7 Correct 43 ms 504 KB Output is correct
8 Correct 43 ms 632 KB Output is correct
9 Correct 43 ms 504 KB Output is correct
10 Correct 43 ms 528 KB Output is correct
11 Correct 44 ms 504 KB Output is correct
12 Correct 43 ms 504 KB Output is correct
13 Correct 45 ms 504 KB Output is correct
14 Correct 43 ms 632 KB Output is correct
15 Correct 42 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 404 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 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 2 ms 376 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 376 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 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 404 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 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 2 ms 376 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 376 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 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 292 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 504 KB Output is correct
2 Correct 43 ms 504 KB Output is correct
3 Correct 42 ms 532 KB Output is correct
4 Correct 44 ms 504 KB Output is correct
5 Correct 46 ms 508 KB Output is correct
6 Correct 44 ms 504 KB Output is correct
7 Correct 43 ms 504 KB Output is correct
8 Correct 43 ms 632 KB Output is correct
9 Correct 43 ms 504 KB Output is correct
10 Correct 43 ms 528 KB Output is correct
11 Correct 44 ms 504 KB Output is correct
12 Correct 43 ms 504 KB Output is correct
13 Correct 45 ms 504 KB Output is correct
14 Correct 43 ms 632 KB Output is correct
15 Correct 42 ms 504 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 404 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 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 2 ms 376 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 376 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 380 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 380 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 504 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 3 ms 376 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 3 ms 292 KB Output is correct
43 Correct 3 ms 376 KB Output is correct
44 Correct 3 ms 376 KB Output is correct
45 Correct 3 ms 376 KB Output is correct
46 Correct 3 ms 376 KB Output is correct
47 Correct 3 ms 376 KB Output is correct
48 Correct 3 ms 376 KB Output is correct
49 Correct 3 ms 376 KB Output is correct
50 Correct 3 ms 376 KB Output is correct
51 Correct 44 ms 496 KB Output is correct
52 Correct 43 ms 520 KB Output is correct
53 Correct 44 ms 504 KB Output is correct
54 Correct 52 ms 504 KB Output is correct
55 Correct 54 ms 504 KB Output is correct
56 Correct 53 ms 504 KB Output is correct
57 Correct 58 ms 500 KB Output is correct
58 Correct 57 ms 504 KB Output is correct
59 Correct 59 ms 504 KB Output is correct
60 Correct 54 ms 632 KB Output is correct
61 Correct 54 ms 504 KB Output is correct
62 Correct 54 ms 504 KB Output is correct
63 Correct 51 ms 504 KB Output is correct
64 Correct 51 ms 504 KB Output is correct
65 Correct 51 ms 504 KB Output is correct
66 Correct 51 ms 504 KB Output is correct
67 Correct 50 ms 504 KB Output is correct
68 Correct 50 ms 500 KB Output is correct