fork download
  1. #include <cstdio>
  2. #include <hash_map>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. const int MX = 3e5 + 5;
  7. typedef long long LL;
  8. LL pref[MX], Res = 0;
  9. char a[MX];
  10. int n;
  11.  
  12. LL v(char x)
  13. {
  14. if(x >= 'a' && x <= 'z')
  15. return 1LL << (x - 'a');
  16. return 1LL << (x - 'A' + ('z' - 'a' + 1));
  17. }
  18.  
  19. //map<LL,LL> maski;
  20.  
  21. struct eq
  22. {
  23. bool operator()(LL s1, LL s2) const
  24. {
  25. return s1 == s2;
  26. }
  27. };
  28.  
  29. hash_map<LL,LL> maski;
  30. //hash_map<LL,LL,hash<LL>,eq> maski;
  31.  
  32. int main()
  33. {
  34. scanf("%d%s", &n, a);
  35.  
  36. pref[n] = 0;
  37. for(int i = n-1; i >= 0; -- i)
  38. pref[i] = pref[i+1] xor v(a[i]);
  39.  
  40. maski[0] = 1;
  41.  
  42. for(int i = n-1; i >= 0; -- i)
  43. {
  44. for(int x = 0; x < 62; ++ x)
  45. {
  46. LL maska = 1LL << x;
  47. if(maski.find(pref[i] xor maska) != maski.end())
  48. Res += maski[pref[i] xor maska];
  49. }
  50. if(maski.find(pref[i]) != maski.end())
  51. Res += maski[pref[i]];
  52. maski[pref[i]] ++;
  53. }
  54.  
  55. printf("%lld\n", Res);
  56.  
  57. return 0;
  58. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.8/backward/hash_map:60:0,
                 from prog.cpp:2:
/usr/include/c++/4.8/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
 #warning \
  ^
prog.cpp:29:1: error: ‘hash_map’ does not name a type
 hash_map<LL,LL> maski;
 ^
prog.cpp: In function ‘int main()’:
prog.cpp:40:9: error: ‘maski’ was not declared in this scope
         maski[0] = 1;
         ^
stdout
Standard output is empty