比赛 “Asm.Def战记之太平洋”杯 评测结果 AAWWWWAATT
题目名称 Asm.Def谈笑风生 最终得分 40
用户昵称 VG|Kn. 运行时间 4.648 s
代码语言 C++ 内存使用 0.97 MiB
提交时间 2015-11-02 09:32:43
显示代码纯文本
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int maxm = 100000 + 100;
int m, cz[maxm];

struct node
{
	string xh;
}a[maxm];

int find(int x, string s)
{
	bool b = false;
	int l, ll, lm;
	ll = s.length();
	for (int i = 1; i < x; i++)
	{
		if (cz[i] == 1)
		{
			l = a[i].xh.length();
			lm = max(l,ll);
			for (int j = 0; j < lm; j++)
			{
				if (a[i].xh[j] == '*' || s[j] == '*')
				{
					if (a[i].xh[j] == '*')
					{
						if (s[j] == 'a' || s[j] == 'b' || s[j] == 'c' || s[j] == 'd')
						{
							b = true;
						}
						else
						{
							b = false;
							break;
						}
					}
					else if (s[j] == '*')
					{
						if (a[i].xh[j] == 'a' || a[i].xh[j] == 'b' || a[i].xh[j] == 'c' || a[i].xh[j] == 'd')
						{
							b = true;
						}
						else
						{
							b = false;
							break;
						}
					}
				}
				else
				{
					if (a[i].xh[j] == s[j])
					{
						b = true;
					}
					else
					{
						b = false;
						break;
					}
				}
				if (j == lm-1 && b == true)
				{
					return 1;
				}
			}
		}
		else if (cz[i] == 2)
		{
			continue;
		}
	}
	return 0;
}

int main()
{
	freopen("asm_talk.in","r",stdin);
	freopen("asm_talk.out","w",stdout);
	bool b;
	cin >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> cz[i];
		if (cz[i] == 1)
		{
			cin >> a[i].xh;
		}
		else if (cz[i] == 2)
		{
			cin >> a[i].xh;
			b = find(i, a[i].xh);
			if (b == 1)
			{
				cout << "YES" << endl;
			}
			if (b == 0)
			{
				cout << "NO" << endl;
			}
		}
	}
	return 0;
}