比赛 20140425 评测结果 AAAAAAAAAAAAAA
题目名称 子序列 最终得分 100
用户昵称 Dijkstra 运行时间 0.076 s
代码语言 C++ 内存使用 0.32 MiB
提交时间 2014-04-25 09:00:47
显示代码纯文本
  1. #include<fstream>
  2. #include<vector>
  3. #include<string>
  4. using namespace std;
  5. ifstream fin("subsequence.in");
  6. ofstream fout("subsequence.out");
  7. vector<int>ch[256];
  8. string ST;
  9. int N,L,p;
  10. string st;
  11. int main()
  12. {
  13. fin>>ST>>N;
  14. int i,j,k;
  15. L=ST.length();
  16. for(i=0;i<L;i++) ch[int(ST[i])].push_back(i);
  17. for(i=0;i<N;i++)
  18. {
  19. fin>>st;
  20. int l=st.length();
  21. int p=-1;
  22. bool flag2=0;
  23. for(j=0;j<l;j++)
  24. {
  25. char c=st[j];
  26. if(ch[int(c)].empty())
  27. {
  28. fout<<"No"<<endl;
  29. flag2=1;
  30. break;
  31. }
  32. bool flag=0;
  33. for(k=0;k<ch[int(c)].size();k++)
  34. {
  35. if(ch[int(c)].at(k)>p)
  36. {
  37. p=ch[int(c)].at(k);
  38. flag=1;
  39. break;
  40. }
  41. }
  42. if(!flag)
  43. {
  44. fout<<"No"<<endl;
  45. flag2=1;
  46. break;
  47. }
  48. }
  49. if(!flag2) fout<<"Yes"<<endl;
  50. }
  51. return 0;
  52. }