Submission #1104851
Source Code Expand
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <vector> #include <map> using namespace std; bool is_match(vector<string> &ns, vector<string> &ms, int i_, int j_, int m){ for(int i = 0;i<m;++i){ for(int j = 0;j<m;++j){ if(ns[i+i_][j+j_] != ms[i][j]){ return false; } } } return true; } string matching(vector<string> &ns, vector<string> &ms, int n, int m){ for(int i = 0;i < n-m+1;++i){ for(int j = 0;j < n-m+1;++j){ if(!is_match(ns, ms, i, j, m)){ continue; } else return "Yes"; } } return "No"; } int main(void) { int n,m; vector<string> ns, ms; cin >> n >> m; for(int i = 0;i < n;++i){ string buf; cin >> buf; ns.push_back(buf); } for(int i = 0;i < m;++i){ string buf; cin >> buf; ms.push_back(buf); } cout << matching(ns, ms, n, m) << endl; /* for(int i = 0;i < n;++i){ cout << ns[i] << endl; } for(int i = 0;i < m;++i){ cout << ms[i] << endl; } */ return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Template Matching |
User | maodao |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1095 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
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 |