답안 #733402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733402 2023-04-30T16:25:50 Z rainboy 공주님의 정원 (KOI11_flower) C
18 / 18
32 ms 2492 KB
#include <stdio.h>

#define N	100000
#define MD	365

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

unsigned int X = 12345;

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

int dd[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int idx(int m, int d) {
	int h;

	for (h = 0; h < m; h++)
		d += dd[h];
	return d;
}

int ll[N], rr[N];

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 (ll[ii[j]] == ll[i_])
				j++;
			else if (ll[ii[j]] < ll[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 ii[N];
	int n, l_, r_, i, r, r1, k;

	scanf("%d", &n), l_ = idx(2, 0), r_ = idx(10, 29);
	for (i = 0; i < n; i++) {
		int ml, dl, mr, dr;

		scanf("%d%d%d%d", &ml, &dl, &mr, &dr), ml--, dl--, mr--, dr--;
		ll[i] = idx(ml, dl), rr[i] = idx(mr, dr);
	}
	for (i = 0; i < n; i++)
		ii[i] = i;
	sort(ii, 0, n);
	r = l_, k = 0, i = 0;
	while (r <= r_) {
		r1 = r;
		while (i < n && ll[ii[i]] <= r)
			r1 = max(r1, rr[ii[i++]]);
		if (r == r1) {
			printf("0\n");
			return 0;
		}
		r = r1, k++;
	}
	printf("%d\n", k);
	return 0;
}

Compilation message

flower.c: In function 'main':
flower.c:49:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |  scanf("%d", &n), l_ = idx(2, 0), r_ = idx(10, 29);
      |  ^~~~~~~~~~~~~~~
flower.c:53:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |   scanf("%d%d%d%d", &ml, &dl, &mr, &dr), ml--, dl--, mr--, dr--;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 288 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 224 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 3 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 472 KB Output is correct
2 Correct 6 ms 468 KB Output is correct
3 Correct 10 ms 524 KB Output is correct
4 Correct 13 ms 684 KB Output is correct
5 Correct 22 ms 880 KB Output is correct
6 Correct 21 ms 968 KB Output is correct
7 Correct 32 ms 1752 KB Output is correct
8 Correct 31 ms 2304 KB Output is correct
9 Correct 31 ms 2492 KB Output is correct
10 Correct 30 ms 2348 KB Output is correct