标签:using main div put clu blog petya ios 思路
思路:
模拟。
实现:
1 #include <iostream> 2 using namespace std; 3 4 string a, b; 5 int m, x, y, ok[30]; 6 7 bool solve() 8 { 9 if (y < x - 1) return false; 10 int i = 0, j = 0; 11 for (; i < x; i++, j++) 12 { 13 if (a[i] >= ‘a‘ && a[i] <= ‘z‘) 14 { 15 if (a[i] != b[j]) return false; 16 } 17 else if (a[i] == ‘?‘) 18 { 19 if (!ok[b[j] - ‘a‘]) return false; 20 } 21 else 22 { 23 int tmp = j; 24 for (; j < tmp + y - x + 1; j++) 25 { 26 if (ok[b[j] - ‘a‘]) return false; 27 } 28 j--; 29 } 30 } 31 return j == y; 32 } 33 34 int main() 35 { 36 string str; 37 cin >> str; 38 int n = str.length(); 39 for (int i = 0; i < n; i++) 40 { 41 ok[str[i] - ‘a‘] = 1; 42 } 43 cin >> a >> m; 44 x = a.length(); 45 for (int i = 0; i < m; i++) 46 { 47 cin >> b; 48 y = b.length(); 49 if (solve()) puts("YES"); 50 else puts("NO"); 51 } 52 return 0; 53 }
标签:using main div put clu blog petya ios 思路
原文地址:http://www.cnblogs.com/wangyiming/p/7258366.html