Guest User

Untitled

a guest
Dec 15th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define in freopen("input.txt","r",stdin);
  3. #define out freopen("output.txt","w",stdout);
  4. using namespace std;
  5. int main()
  6. {
  7. // in;
  8. // out;
  9. string s;
  10. cin >> s;
  11. int ans = 0 , ind1 = 0 , ind2 = 0 , i , j;
  12. for( i = 0; i < s.size(); i ++ ){
  13. int kol = 0;
  14. for( j = i; j < s.size(); j ++ ){
  15. if( s[j] == '(' )kol ++;
  16. else kol --;
  17. if( kol < 0 )break;
  18. if( kol == 0 ){
  19. if( ans < j - i + 1 ){
  20. ans = j - i + 1;
  21. ind1 = i;
  22. ind2 = j;
  23. }
  24. }
  25. }
  26. }
  27. for( i = ind1; i <= ind2; i ++ )cout << s[i];
  28. cout << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment