Submission #1104853


Source Code Expand

#include <stdio.h>
#include <stdlib.h>

int main() {
  int N, M;
  scanf("%d %d%*c", &N, &M);
  int i, j;
  int** A, **B;
  A = (int**)malloc(sizeof(int) * N);
  for (i = 0; i < N; i++)
    A[i] = (int*)malloc(sizeof(int) * N);
  B = (int**)malloc(sizeof(int) * M);
  for (i = 0; i < M; i++)
    B[i] = (int*)malloc(sizeof(int) * M);
  char c;
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      scanf("%c", &c);
      if (c == '.')
        A[i][j] = 0;
      else
        A[i][j] = 1;
    }
    scanf("%*c");
  }
  for (i = 0; i < M; i++) {
    for (j = 0; j < M; j++) {
      scanf("%c", &c);
      if (c == '.')
        B[i][j] = 0;
      else
        B[i][j] = 1;
    }
    scanf("%*c");
  }
  int k, l;
  int success;
  for (i = 0; i <= N - M; i++) {
    for (j = 0; j <= N - M; j++) {
      success = 1;
      for (k = 0; k < M; k++) {
        for (l = 0; l < M; l++) {
          if (A[i + k][j + l] != B[k][l]) {
            success = 0;
            break;
          }
          if (!success) break;
        }
      }
      if (success) break;
    }
    if (success) break;
  }
  if (success) printf("Yes\n");
  else printf("No\n");
  for (i = 0; i < N; i++)
    free(A[i]);
  for (i = 0; i < M; i++)
    free(B[i]);
  free(A);
  free(B);
  return 0;
}

Submission Info

Submission Time
Task B - Template Matching
User brln_49th
Language C (GCC 5.4.1)
Score 0
Code Size 1337 Byte
Status RE
Exec Time 159 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:6:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d%*c", &N, &M);
   ^
./Main.c:18:7: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
       scanf("%c", &c);
       ^
./Main.c:24:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%*c");
     ^
./Main.c:28:7: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
       scanf("%c", &c);
       ^
./Main.c:34:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%*c");
     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 1
RE × 1
AC × 2
RE × 8
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 128 KB
sample_02.txt RE 159 ms 128 KB
subtask_1_01.txt AC 1 ms 128 KB
subtask_1_02.txt RE 100 ms 128 KB
subtask_1_03.txt RE 96 ms 128 KB
subtask_1_04.txt RE 98 ms 128 KB
subtask_1_05.txt RE 97 ms 128 KB
subtask_1_06.txt RE 96 ms 128 KB
subtask_1_07.txt RE 97 ms 128 KB
subtask_1_08.txt RE 98 ms 128 KB