fork download
  1. #pragma GCC optimize("O3,unroll-loops")
  2. #pragma GCC optimize("inline")
  3. #pragma GCC optimize("-fgcse")
  4. #pragma GCC optimize("-fgcse-lm")
  5. #pragma GCC optimize("-fipa-sra")
  6. #pragma GCC optimize("-ftree-pre")
  7. #pragma GCC optimize("-ftree-vrp")
  8. #pragma GCC optimize("-fpeephole2")
  9. #pragma GCC optimize("-ffast-math")
  10. #pragma GCC optimize("-fsched-spec")
  11. #pragma GCC optimize("-falign-jumps")
  12. #pragma GCC optimize("-falign-loops")
  13. #pragma GCC optimize("-falign-labels")
  14. #pragma GCC optimize("-fdevirtualize")
  15. #pragma GCC optimize("-fcaller-saves")
  16. #pragma GCC optimize("-fcrossjumping")
  17. #pragma GCC optimize("-fthread-jumps")
  18. #pragma GCC optimize("-funroll-loops")
  19. #pragma GCC optimize("fast-math")
  20. #pragma GCC optimize("-freorder-blocks")
  21. #pragma GCC optimize("-fschedule-insns")
  22. #pragma GCC optimize("inline-functions")
  23. #pragma GCC optimize("-ftree-tail-merge")
  24. #pragma GCC optimize("-fschedule-insns2")
  25. #pragma GCC optimize("-fstrict-aliasing")
  26. #pragma GCC optimize("-falign-functions")
  27. #pragma GCC optimize("-fcse-follow-jumps")
  28. #pragma GCC optimize("-fsched-interblock")
  29. #pragma GCC optimize("-fpartial-inlining")
  30. #pragma GCC optimize("no-stack-protector")
  31. #pragma GCC optimize("-freorder-functions")
  32. #pragma GCC optimize("-findirect-inlining")
  33. #pragma GCC optimize("-fhoist-adjacent-loads")
  34. #pragma GCC optimize("-frerun-cse-after-loop")
  35. #pragma GCC optimize("inline-small-functions")
  36. #pragma GCC optimize("-finline-small-functions")
  37. #pragma GCC optimize("-ftree-switch-conversion")
  38. #pragma GCC optimize("-foptimize-sibling-calls")
  39. #pragma GCC optimize("-fexpensive-optimizations")
  40. #pragma GCC optimize("inline-functions-called-once")
  41. #pragma GCC optimize("-fdelete-null-pointer-checks")
  42. #include<bits/stdc++.h>
  43. using namespace std;
  44. #define fi first
  45. #define se second
  46. #define ll long long
  47. #define el cout<<"\n"
  48. #define sz(x) (int)(x).size()
  49. #define all(x) (x).begin(),(x).end()
  50. #define f0(i,n) for(int i=0;i<n;++i)
  51. #define f1(i,n) for(int i=1;i<=n;++i)
  52. #define fz(i,a,n,z) for(int i=a;i<n;i+=z)
  53. #define rep(i,a,n,z) for(int i=a;i>n;i-=z)
  54. #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  55. #define file(name) freopen(name".inp","r",stdin);freopen(name".out","w",stdout);
  56. int main() {
  57. faster
  58. int n;
  59. cin >> n;
  60. string s;
  61. int pre[n + 5] = {}, D[3] = {};
  62. f1(i, n) {
  63. cin >> s;
  64. pre[i] = pre[i - 1] + (s[s.size() - 1] - 48);
  65. pre[i] %= 2;
  66. D[pre[i]]++;
  67. }
  68. cout << (D[0] + (D[0] * (D[0] - 1) / 2)) + ((D[1] * (D[1] - 1)) / 2);
  69.  
  70. }
  71.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
1