Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int k; scanf("%d",&k);
- for(int t=1;t<=k;t++){
- string a,ans;
- cin>>a;
- int m=a.size(),f=0,l=0;
- for(int i=0;i<m;i++){
- int u=a[i]-'0';
- if(u==0){
- for(int j=0;j<l;j++){
- ans=ans+')';
- }l=0;f=0;
- }
- if(u<l){
- for(int j=0;j<l-u;j++){
- ans=ans+')';f--;
- }l=u;
- }
- if(u>f){
- for(int j=0;j<u-f;j++){
- ans=ans+'(';
- }f=u;
- }
- l=max(u,l);
- ans=ans+a[i];
- }
- for(int i=0;i<l;i++){
- ans=ans+')';
- }
- printf("Case #%d: ",t);
- cout<<ans<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement