Submission #1768859


Source Code Expand

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int N, M; cin >> N >> M;
	vector<string> A(N, string(N, '.'));
	vector<string> B(M, string(M, '.'));

	rep (i, N) cin >> A[i];
	rep (j, M) cin >> B[j];

	bool match = false;
	for (int i = 0; i < N - M + 1; ++i){
		for (int j = 0; j < N - M + 1; ++j){
			bool curr = true;
//			cerr << i << " rows: " << j << " cols:" << endl;
			for (int k = 0; k < M; ++k){
				for (int l = 0; l < M; ++l){ 
					if (A[i+k][j+l] != B[k][l]){
						curr = false;
						break;
					} // end if
				} // end for
				if (!curr) break;
			} // end for
			match |= curr;
		} // end for
	} // end for

	cout << (match ? "Yes" : "No") << endl;

	return 0;
}

Submission Info

Submission Time
Task B - Template Matching
User ty70
Language C++14 (GCC 5.4.1)
Score 200
Code Size 905 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