Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- int main()
- {
- _test
- {
- string s;
- cin>>s;
- int n = s.size();
- string a = "";
- string b = "";
- a.pb('(');
- while(a.size() < 2*n)
- {
- if(a.back() == '(') a.pb(')');
- else a.pb('(');
- }
- while(b.size() < n) b.pb('(');
- while(b.size() < 2*n) b.pb(')');
- if(a.find(s) == string::npos)
- cout<<"YES\n"<<a<<"\n";
- else if(b.find(s) == string::npos)
- cout<<"YES\n"<<b<<"\n";
- else
- cout<<"NO\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment