Submission #1103559


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>

using namespace std;
using namespace std::chrono;

vector<string> a, b;
int n, m;

bool check(int s_i, int s_j) {
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j)
      if (a[s_i + i][s_j +j] != b[i][j])
        return false;
  return true;
}

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n >> m;
  a.resize(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  b.resize(m);
  for (int i = 0; i < m; ++i)
    cin >> b[i];

  for (int i = 0; i + m < n; ++i)
    for (int j = 0; j + m < n; ++j)
      if (check(i, j)) {
        cout << "Yes\n";
        return 0;
      }

  cout << "No\n";

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}

Submission Info

Submission Time
Task B - Template Matching
User Elshiko
Language C++14 (GCC 5.4.1)
Score 0
Code Size 951 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
AC × 2
AC × 9
WA × 1
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 256 KB
sample_02.txt AC 1 ms 256 KB
subtask_1_01.txt WA 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 1 ms 256 KB
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 1 ms 256 KB
subtask_1_07.txt AC 1 ms 256 KB
subtask_1_08.txt AC 1 ms 256 KB