比赛 |
20140425 |
评测结果 |
AAAAAAAAAAAAAA |
题目名称 |
子序列 |
最终得分 |
100 |
用户昵称 |
Dijkstra |
运行时间 |
0.076 s |
代码语言 |
C++ |
内存使用 |
0.32 MiB |
提交时间 |
2014-04-25 09:00:47 |
显示代码纯文本
- #include<fstream>
- #include<vector>
- #include<string>
- using namespace std;
- ifstream fin("subsequence.in");
- ofstream fout("subsequence.out");
- vector<int>ch[256];
- string ST;
- int N,L,p;
- string st;
- int main()
- {
- fin>>ST>>N;
- int i,j,k;
- L=ST.length();
- for(i=0;i<L;i++) ch[int(ST[i])].push_back(i);
- for(i=0;i<N;i++)
- {
- fin>>st;
- int l=st.length();
- int p=-1;
- bool flag2=0;
- for(j=0;j<l;j++)
- {
- char c=st[j];
- if(ch[int(c)].empty())
- {
- fout<<"No"<<endl;
- flag2=1;
- break;
- }
- bool flag=0;
- for(k=0;k<ch[int(c)].size();k++)
- {
- if(ch[int(c)].at(k)>p)
- {
- p=ch[int(c)].at(k);
- flag=1;
- break;
- }
- }
- if(!flag)
- {
- fout<<"No"<<endl;
- flag2=1;
- break;
- }
- }
- if(!flag2) fout<<"Yes"<<endl;
- }
- return 0;
- }