Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define in freopen("input.txt","r",stdin);
- #define out freopen("output.txt","w",stdout);
- using namespace std;
- int main()
- {
- // in;
- // out;
- string s;
- cin >> s;
- int ans = 0 , ind1 = 0 , ind2 = 0 , i , j;
- for( i = 0; i < s.size(); i ++ ){
- int kol = 0;
- for( j = i; j < s.size(); j ++ ){
- if( s[j] == '(' )kol ++;
- else kol --;
- if( kol < 0 )break;
- if( kol == 0 ){
- if( ans < j - i + 1 ){
- ans = j - i + 1;
- ind1 = i;
- ind2 = j;
- }
- }
- }
- }
- for( i = ind1; i <= ind2; i ++ )cout << s[i];
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment