Saleh127

cf 1374C

Jun 28th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. test
  10. {
  11. string a;
  12. ll c,d=0,e,f,i,j;
  13. cin>>c>>a;
  14. for(i=0;i<c;i++)
  15. {
  16. if(a[i]=='(')
  17. {
  18. for(j=i+1;j<c;j++)
  19. {
  20. if(a[j]==')')
  21. {
  22. a[i]='0';
  23. a[j]='0';
  24. break;
  25. }
  26. }
  27.  
  28. }
  29. }
  30. for(i=0;i<c;i++)
  31. {
  32. if(a[i]=='(' || a[i]==')')
  33. {
  34. d++;
  35. }
  36. }
  37. cout<<d/2<<endl;
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment