Submission #65831596


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>
int N, M;
int K[312345];
int* A[312345];
int B[312345];
int B_reverse[312345];
int A_max[312345];
int ans[312345];
int main(void) {
int i, j;
if (scanf("%d%d", &N, &M) != 2) return 1;
for (i = 0; i < M; i++) {
if (scanf("%d", &K[i]) != 1) return 1;
A[i] = malloc(sizeof(*A[i]) * K[i]);
if (A[i] == NULL) return 2;
for (j = 0; j < K[i]; j++) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>

int N, M;
int K[312345];
int* A[312345];
int B[312345];

int B_reverse[312345];
int A_max[312345];

int ans[312345];

int main(void) {
	int i, j;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d", &K[i]) != 1) return 1;
		A[i] = malloc(sizeof(*A[i]) * K[i]);
		if (A[i] == NULL) return 2;
		for (j = 0; j < K[i]; j++) {
			if (scanf("%d", &A[i][j]) != 1) return 1;
		}
	}
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &B[i]) != 1) return 1;
		B_reverse[B[i]] = i;
	}

	for (i = 0; i < M; i++) {
		/* 最後に克服する食材が何日目に克服されるかを求める */
		for (j = 0; j < K[i]; j++) {
			int cur = B_reverse[A[i][j]];
			if (A_max[i] < cur) A_max[i] = cur;
		}
		/* その日に食べられるようになる料理をカウントする */
		ans[A_max[i]]++;
	}

	/* 食べられる料理の数を累積和する */
	for (i = 1; i <= N; i++) {
		ans[i] += ans[i - 1];
		printf("%d\n", ans[i]);
	}

	return 0;
}

Submission Info

Submission Time
Task C - Dislike Foods
User mikecat
Language C (gcc 12.2.0)
Score 300
Code Size 1056 Byte
Status AC
Exec Time 92 ms
Memory 20044 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 33
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 1632 KB
00_sample_01.txt AC 1 ms 1748 KB
01_test_00.txt AC 19 ms 2856 KB
01_test_01.txt AC 9 ms 2244 KB
01_test_02.txt AC 5 ms 1976 KB
01_test_03.txt AC 2 ms 1700 KB
01_test_04.txt AC 5 ms 2000 KB
01_test_05.txt AC 2 ms 1852 KB
01_test_06.txt AC 63 ms 6956 KB
01_test_07.txt AC 24 ms 6204 KB
01_test_08.txt AC 57 ms 7376 KB
01_test_09.txt AC 52 ms 6308 KB
01_test_10.txt AC 56 ms 6444 KB
01_test_11.txt AC 64 ms 11092 KB
01_test_12.txt AC 66 ms 9256 KB
01_test_13.txt AC 21 ms 5432 KB
01_test_14.txt AC 70 ms 7104 KB
01_test_15.txt AC 33 ms 4476 KB
01_test_16.txt AC 90 ms 18496 KB
01_test_17.txt AC 37 ms 7744 KB
01_test_18.txt AC 78 ms 9876 KB
01_test_19.txt AC 63 ms 13256 KB
01_test_20.txt AC 81 ms 19228 KB
01_test_21.txt AC 92 ms 19944 KB
01_test_22.txt AC 92 ms 19936 KB
01_test_23.txt AC 85 ms 20044 KB
01_test_24.txt AC 19 ms 4444 KB
01_test_25.txt AC 21 ms 2964 KB
01_test_26.txt AC 25 ms 8784 KB
01_test_27.txt AC 22 ms 6424 KB
01_test_28.txt AC 18 ms 2856 KB
01_test_29.txt AC 25 ms 8632 KB
01_test_30.txt AC 1 ms 1772 KB


2025-05-17 (Sat)
00:22:44 +09:00