比赛 NOIP模拟赛1 评测结果 WWWWWWWWWW
题目名称 叉叉 最终得分 0
用户昵称 LYN-- 运行时间 0.096 s
代码语言 C++ 内存使用 0.19 MiB
提交时间 2018-02-08 21:11:09
显示代码纯文本
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. using namespace std;
  5. int ans;
  6. int main()
  7. {
  8. freopen("xxxx.in","r",stdin);
  9. freopen("xxxx.out","w",stdout);
  10. int lg;
  11. string sd;
  12. cin>>sd;
  13. lg=sd.length();
  14. int am[200],jh[200];
  15. for(char ch='a';ch<='z';ch++)
  16. am[ch]=0;
  17. for(char sh='a';sh<='z';sh++)
  18. jh[sh]=0;
  19. for(int i=0;i<lg;i++)
  20. {
  21. if(am[sd[i]]==0)
  22. {
  23. am[sd[i]]=1;
  24. jh[sd[i]]=i;
  25. }
  26. else
  27. {
  28. for(int j=jh[sd[i]]+1;j<i;j++)
  29. {
  30. if(am[sd[j]]==1)
  31. ans++;
  32. }
  33. am[sd[i]]=0;
  34. }
  35. }
  36. cout<<ans;
  37. }