Advertisement
Saleh127

CC compiler

Oct 9th, 2020
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9. string a;
  10. ll i,j,k=0;
  11. test
  12. {
  13. cin>>a;
  14. j=0;
  15. k=0;
  16. for(i=0;i<a.size();i++)
  17. {
  18. if(a[i]=='<')
  19. {
  20. j++;
  21. }
  22. else if(a[i]=='>')
  23. {
  24. j--;
  25. }
  26. if(j==0)
  27. {
  28. k=max(k,i+1);
  29. }
  30. else if(j<0)
  31. {
  32. break;
  33. }
  34. }
  35. cout<<k<<endl;
  36. }
  37.  
  38.  
  39. return 0;
  40. }
Advertisement
RAW Paste Data Copied
Advertisement