fork download
  1. #include <algorithm>
  2. #include <iomanip>
  3. #include <iostream>
  4. #include <vector>
  5. #include <set>
  6. #include <numeric>
  7. #include <map>
  8. #include <unordered_map>
  9. #include <stack>
  10. #include <queue>
  11. using namespace std;
  12. #define all(a) a.begin(), a.end()
  13. #define ll long long
  14. #define fo(i,n) for (long long i = 0; i < n; i++)
  15. int main()
  16. {
  17. ll i,a,b,c,ans;
  18. ios_base::sync_with_stdio(false);
  19. string input;
  20. cin.tie(0); cout.tie(0);
  21. cin >> i;
  22. while (i--)
  23. {
  24. cin >> a;
  25. cin >> input;
  26. b = 0;
  27. c = 0;
  28. for (char k : input)
  29. {
  30. if (k == '-')
  31. {
  32. b++;
  33. }
  34. else
  35. {
  36. c++;
  37. }
  38. }
  39. if (b < 2 || c < 1)
  40. {
  41. ans = 0;
  42. }
  43. else
  44. {
  45. if (b%2 == 0)
  46. {
  47. ans = (b/2) * (b/2) * c;
  48. }
  49. else
  50. {
  51. ans = (b/2) * (b/2 + 1) * c;
  52. }
  53. }
  54. cout << ans << '\n';
  55. }
  56. }
Success #stdin #stdout 0.01s 5276KB
stdin
8
3
--_
5
__-__
9
--__-_---
4
_--_
10
_-_-_-_-_-
7
_------
1
-
2
_-
stdout
1
0
27
2
30
9
0
0