CF832B Petya and Exam

Posted 王宜鸣

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF832B Petya and Exam相关的知识,希望对你有一定的参考价值。

思路:

模拟。

实现:

 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 }

 

以上是关于CF832B Petya and Exam的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces_832B: Petya and Exam

Codeforces Round #425 (Div. 2) Problem B Petya and Exam - 暴力

Codeforces Round #425 (Div. 2) B. Petya and Exam(暴力大法好)

CF886C Petya and Catacombs

CF1042D Petya and Array

CF1082G Petya and Graph