Submission #72980753


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>
struct event_s {
int sx, dx, y, delta;
};
/* yydelta (delta) */
int cmp(const void* x, const void* y) {
struct event_s a = *(const struct event_s*)x, b = *(const struct event_s*)y;
return
((a.y > b.y) - (a.y < b.y)) * 2 +
((a.delta < b.delta) - (a.delta > b.delta));
}
int n;
int a, b;
int p[5123], q[5123], r[5123], s[5123];
struct event_s events[5123 * 2];
int counts[1123456];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>

struct event_s {
	int sx, dx, y, delta;
};

/* yの昇順、yが同じならdeltaの降順 (deltaが正のほうが先) */
int cmp(const void* x, const void* y) {
	struct event_s a = *(const struct event_s*)x, b = *(const struct event_s*)y;
	return
		((a.y > b.y) - (a.y < b.y)) * 2 +
		((a.delta < b.delta) - (a.delta > b.delta));
}

int n;
int a, b;
int p[5123], q[5123], r[5123], s[5123];

struct event_s events[5123 * 2];
int counts[1123456];
int counts_of_counts[5123];
int areas[5123];

int main(void) {
	int i;
	int max_sheets = 0;
	if (scanf("%d", &n) != 1) return 1;
	if (scanf("%d%d", &a, &b) != 2) return 1;
	for (i = 0; i < n; i++) {
		if (scanf("%d%d%d%d", &p[i], &q[i], &r[i], &s[i]) != 4) return 1;
		events[i * 2] = (struct event_s){ p[i], r[i], q[i], 1 };
		events[i * 2 + 1] = (struct event_s){ p[i], r[i], s[i] + 1, -1 };
	}
	events[n * 2] = (struct event_s){ 0, 0, 0, 0 };
	qsort(events, n * 2 + 1, sizeof(*events), cmp);
	for (i = 1; i <= n * 2; i++) {
		int j;
		for (j = 1; j <= max_sheets; j++) {
			areas[j] += counts_of_counts[j] * (events[i].y - events[i - 1].y);
		}
		for (j = events[i].sx; j <= events[i].dx; j++) {
			counts_of_counts[counts[j]]--;
			counts[j] += events[i].delta;
			counts_of_counts[counts[j]]++;
		}
		max_sheets += events[i].delta;
	}
	for (i = n; i > 0; i--) {
		if (areas[i] > 0) {
			printf("%d\n%d\n", i, areas[i]);
			return 0;
		}
	}
	puts("ERROR!");
	return 0;
}

Submission Info

Submission Time
Task origami - 折り紙 (Origami)
User mikecat
Language C23 (GCC 14.2.0)
Score 100
Code Size 1519 Byte
Status AC
Exec Time 12 ms
Memory 5424 KiB

Judge Result

Set Name Set01 Set02 Set03 Set04 Set05 Set06 Set07 Set08 Set09 Set10
Score / Max Score 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10
Status
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
Set Name Test Cases
Set01 01
Set02 02
Set03 03
Set04 04
Set05 05
Set06 06
Set07 07
Set08 08
Set09 09
Set10 10
Case Name Status Exec Time Memory
01 AC 1 ms 1748 KiB
02 AC 1 ms 1752 KiB
03 AC 1 ms 1848 KiB
04 AC 1 ms 1756 KiB
05 AC 2 ms 1972 KiB
06 AC 12 ms 2036 KiB
07 AC 4 ms 2012 KiB
08 AC 3 ms 2140 KiB
09 AC 2 ms 2136 KiB
10 AC 5 ms 5424 KiB


2026-02-04 (Wed)
04:04:07 +09:00