#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
using namespace std;
int main()
{
int n,m;
map<string,int> a;
while (~scanf("%d%d",&n,&m))
{
char s[100];
a.clear();
for (int i = 0; i < n; i++)
{
scanf("%s", s);
a[s] = 1;
}
while (m--)
{
scanf("%s",s);
if (a[s]==1)
printf("NO\n");
else
{
a[s]=1;
printf("YES\n");
}
}
}
return 0;
}
本文介绍了一种使用C++编程语言及标准模板库(map)来解决字符串匹配问题的方法。通过读取输入的字符串集合并利用map进行高效查找,程序能够判断新输入的字符串是否已存在于集合中,并据此输出相应的结果。此方法适用于需要频繁进行字符串匹配的应用场景。
1890

被折叠的 条评论
为什么被折叠?



