답안 #309996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309996 2020-10-05T09:16:25 Z ttnhuy313 Mountains (IOI17_mountains) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
#define sqr(a) (a * a)
typedef pair <int, int> ii;

const int N = 2005;
int dp[N][N];

int cross(ii a, ii b) {
	return a.first * b.second - a.second * b.first;
}

bool ccw(ii a, ii b, ii c) {
	return cross(ii(b.first - a.first, b.second - a.second), ii(c.first - a.first, c.second - a.second)) > 0;
}

int maximum_deevs(vector <int> y) {
	int n = y.size();
	for (int r = 0; r < n; ++r) {
		dp[r][r] = 1;
		if (r == 0) continue;
		dp[r - 1][r] = 1;
		int xx = 1, yy = y[r] - y[r - 1], sum = 0, lastSeen = r - 1, id = r - 1;
		for (int l = r - 2; l >= 0; --l) {
			int curx = r - l, cury = y[r] - y[l];
			if (sqr(curx) * (sqr(xx) + sqr(yy)) < sqr(xx) * (sqr(curx) + sqr(cury))) {
				xx = curx;
				yy = cury;
				id = l;
			}
			if (ccw(ii(r, y[r]), ii(id, y[id]), ii(l, y[l]))) { // cross the mountain
				dp[l][r] = sum + dp[l][lastSeen - 1] + 1;
			} else {
				sum += dp[l + 1][lastSeen - 1];
				lastSeen = l;
			}
			dp[l][r] = max(dp[l][r], dp[l][r - 1]);
		}
	}

	return dp[0][n - 1];
}

Compilation message

/tmp/ccXw1CDU.o: In function `main':
grader.cpp:(.text.startup+0x1de): undefined reference to `maximum_deevs(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status