fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while(t--)
  8. {
  9. int n,c=0,d=0;
  10. cin >> n;
  11. string s;
  12. cin >> s;
  13. for(int i=0;i<n;i++)
  14. {
  15. if(s[i]=='-')
  16. c++;
  17. else
  18. d++;
  19. }
  20. if(c%2==0)
  21. {
  22. int m = c/2;
  23. cout << m*m*d << endl;
  24. }
  25. else
  26. {
  27. int m = c/2 ;
  28. cout << m*(m+1)*d << endl;
  29. }
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0s 5328KB
stdin
8
3
--_
5
__-__
9
--__-_---
4
_--_
10
_-_-_-_-_-
7
_------
1
-
2
_-
stdout
1
0
27
2
30
9
0
0