Submission #1587622


Source Code Expand

#include <bits/stdc++.h>
#include <regex>
using namespace std;
typedef long long ll;

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

signed main() {
	int n, m;
	cin >> n >> m;
	string a[n], b[m];
	for (size_t i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (size_t i = 0; i < m; i++) {
		cin >> b[i];
	}
	bool finded = false;
	for (size_t i = 0; i < n - m + 1 && !finded; i++) {
		for (size_t j = 0; j < n - m + 1; j++) {
			bool ok = true;
			for (size_t y = 0; y < m && ok; y++) {
				// cout << b[y] << ":" << a[y + i].substr(j, m) << endl << endl;
				if (b[y] != a[y + i].substr(j, m)) {
					ok = false;
				}
			}
			if (ok) {
				finded = true;
				break;
			}
		}
	}
	cout << (finded ? "Yes" : "No") << endl;
}

Submission Info

Submission Time
Task B - Template Matching
User elzup
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1036 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 10
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 AC 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