const int maxn = 25; char smap[maxn][maxn], emap[maxn][maxn]; int num[(1 << 20) + 10], all; int nowi,nowj; void pre() { all = (1 << 20); num[0] = 0; FF(i, 1, all) num[i] = num[i >> 1] + (i & 1); } int main() { int sn, sm, en, em; RII(en, em); REP(i, en) RS(emap[i]); RII(sn, sm); REP(i, sn) RS(smap[i]); pre(); bool f = 0; all = (1 << sn); FF(s, 1, all) { if (num[s] != en) continue; nowj = 0; REP(j, sm) { nowi = 0; REP(row, sn) if ((1 << row) & s) { if (smap[row][j] != emap[nowi][nowj]) break; nowi++; } if (nowi == en) { nowj++; } if (nowj >= em) { f = 1; goto end; } } } end:; if (f) puts("Yes"); else puts("No"); return 0; }
Subimage Recognition,布布扣,bubuko.com
原文:http://blog.csdn.net/wty__/article/details/38441753