Submission #76352577


Source Code Expand

Copy
#include <stdio.h>
#include <string.h>
int N;
int A[16], B[16];
int M;
char S[212345][16];
/* [][][] */
char exists[16][16][32];
int main(void) {
int i, j;
if (scanf("%d", &N) != 1) return 1;
for (i = 0; i < N; i++) {
if (scanf("%d%d", &A[i], &B[i]) != 2) return 1;
B[i]--;
}
if (scanf("%d", &M) != 1) return 1;
for (i = 0; i < M; i++) {
if (scanf("%15s", S[i]) != 1) return 1;
}
for (i = 0; i < M; i++) {
int len = (int)strlen(S[i]);
for (j = 0; j < len; j++) {
int id = S[i][j] - 'a';
if (0 <= id && id < 26) exists[j][len][id] = 1;
}
}
for (i = 0; i < M; i++) {
int yes = strlen(S[i]) == N;
for (j = 0; yes && S[i][j] != '\0'; j++) {
int id = S[i][j] - 'a';
yes = 0 <= id && id < 26 && exists[B[j]][A[j]][id];
}
puts(yes ? "Yes" : "No");
}
return 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <string.h>

int N;
int A[16], B[16];
int M;
char S[212345][16];

/* [何文字目][長さ][文字] */
char exists[16][16][32];

int main(void) {
	int i, j;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &A[i], &B[i]) != 2) return 1;
		B[i]--;
	}
	if (scanf("%d", &M) != 1) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%15s", S[i]) != 1) return 1;
	}

	for (i = 0; i < M; i++) {
		int len = (int)strlen(S[i]);
		for (j = 0; j < len; j++) {
			int id = S[i][j] - 'a';
			if (0 <= id && id < 26) exists[j][len][id] = 1;
		}
	}

	for (i = 0; i < M; i++) {
		int yes = strlen(S[i]) == N;
		for (j = 0; yes && S[i][j] != '\0'; j++) {
			int id = S[i][j] - 'a';
			yes = 0 <= id && id < 26 && exists[B[j]][A[j]][id];
		}
		puts(yes ? "Yes" : "No");
	}

	return 0;
}

Submission Info

Submission Time
Task C - Fishbones
User mikecat
Language C23 (GCC 14.2.0)
Score 300
Code Size 871 Byte
Status AC
Exec Time 19 ms
Memory 4868 KiB

Compile Error

Main.c: In function ‘main’:
Main.c:33:40: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
   33 |                 int yes = strlen(S[i]) == N;
      |                                        ^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 25
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt
All 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 1 ms 1672 KiB
00-sample-02.txt AC 1 ms 1624 KiB
01-01.txt AC 3 ms 2132 KiB
01-02.txt AC 10 ms 3432 KiB
01-03.txt AC 17 ms 4680 KiB
01-04.txt AC 10 ms 3432 KiB
01-05.txt AC 14 ms 3776 KiB
01-06.txt AC 12 ms 3752 KiB
01-07.txt AC 15 ms 4840 KiB
01-08.txt AC 16 ms 4868 KiB
01-09.txt AC 3 ms 1976 KiB
01-10.txt AC 10 ms 3432 KiB
01-11.txt AC 3 ms 2136 KiB
01-12.txt AC 16 ms 4424 KiB
01-13.txt AC 12 ms 3716 KiB
01-14.txt AC 10 ms 3332 KiB
01-15.txt AC 17 ms 4752 KiB
01-16.txt AC 19 ms 4868 KiB
01-17.txt AC 16 ms 4664 KiB
01-18.txt AC 17 ms 4840 KiB
01-19.txt AC 16 ms 4668 KiB
01-20.txt AC 16 ms 4668 KiB
01-21.txt AC 16 ms 4840 KiB
01-22.txt AC 16 ms 4664 KiB
01-23.txt AC 16 ms 4832 KiB


2026-06-02 (Tue)
22:22:11 +09:00