Submission #485886

#TimeUsernameProblemLanguageResultExecution timeMemory
485886rainboySIR (COI15_sir)C11
51 / 100
97 ms716 KiB
#include <stdio.h>

#define N	3000
#define M	3000

long long max(long long a, long long b) { return a > b ? a : b; }

long long cross2(int x1, int y1, int x2, int y2) {
	return (long long) x1 * y2 - (long long) x2 * y1;
}

long long cross(int x0, int y0, int x1, int y1, int x2, int y2) {
	return cross2(x1 - x0, y1 - y0, x2 - x0, y2 - y0);
}

int main() {
	static int xx[N + M], yy[N + M];
	int n, m, i, i1, i2, j;
	long long ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	scanf("%d", &m);
	for (j = 0; j < m; j++)
		scanf("%d%d", &xx[n + j], &yy[n + j]);
	ans = 0;
	for (i1 = 0; i1 < n; i1++) {
		int lower, upper;
		long long area;

		lower = 1, upper = n;
		while (upper - lower > 1) {
			int d = (lower + upper) / 2, good;

			i2 = (i1 + d) % n;
			good = 1;
			for (j = 0; j < m; j++)
				if (cross(xx[i1], yy[i1], xx[i2], yy[i2], xx[n + j], yy[n + j]) <= 0) {
					good = 0;
					break;
				}
			if (good)
				lower = d;
			else
				upper = d;
		}
		i2 = (i1 + lower) % n;
		area = cross2(xx[i2], yy[i2], xx[i1], yy[i1]);
		for (i = i1; i != i2; i = (i + 1) % n)
			area += cross2(xx[i], yy[i], xx[(i + 1) % n], yy[(i + 1) % n]);
		ans = max(ans, area);
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message (stderr)

sir.c: In function 'main':
sir.c:21:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
sir.c:23:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sir.c:24:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d", &m);
      |  ^~~~~~~~~~~~~~~
sir.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d%d", &xx[n + j], &yy[n + j]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...