제출 #536649

#제출 시각아이디문제언어결과실행 시간메모리
536649rainboy허수아비 (JOI14_scarecrows)C11
15 / 100
41 ms528 KiB
#include <stdio.h>

#define N	5000

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

int *zz;

void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;

		while (j < k)
			if (zz[ii[j]] == zz[i_])
				j++;
			else if (zz[ii[j]] < zz[i_]) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		sort(ii, l, i);
		l = k;
	}
}

int main() {
	static int xx[N], yy[N], yy_[N], ii[N];
	static char used[N];
	int n, i, i_, j, y, cnt;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	for (i = 0; i < n; i++)
		ii[i] = i;
	zz = xx, sort(ii, 0, n);
	for (i = 0; i < n; i++)
		yy_[xx[ii[i]] = i] = yy[ii[i]];
	zz = yy, sort(ii, 0, n);
	cnt = 0;
	for (i = 0; i < n; i++) {
		i_ = ii[i];
		y = -1;
		for (j = xx[i_] - 1; j >= 0; j--)
			if (used[j] && y < yy_[j])
				y = yy_[j], cnt++;
		used[xx[i_]] = 1;
	}
	printf("%d\n", cnt);
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

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