题目描述
暴力求解
样例
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
getchar();
map<int,string> a,b;
for(int i = 1; i <= n; i++)
{
string x;
cin >>x;
b[i] = x;
transform(x.begin(),x.end(),x.begin(),::tolower);
a[i] = x;
}
string s;
cin >> s;
transform(s.begin(),s.end(),s.begin(),::tolower);
int j ,k;
int flag;
string temp;
for(int i = 1; i <= n; i++)
{
temp = a[i];
j = 0;
k = 0;
while(j < s.size())
{
flag = 0;
if(temp[k] == s[j])
{
j++;
k++;
}
else if(temp[k] != s[j] && s[j] == '[')
{
while(s[j] !=']')
{
if(s[j] == temp[k]) flag = 1;
j++;
}
if(flag == 1)
{
k++;
j++;
}
else break;
}
else if(temp[k] != s[j] && s[j] != '[') break;
}
if(j == s.size())
{
cout << i <<" " << b[i] <<endl;
}
}
return 0;
}
强啊强啊
王神好厉害!!!