-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNesting_depth.cpp
More file actions
51 lines (44 loc) · 844 Bytes
/
Nesting_depth.cpp
File metadata and controls
51 lines (44 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// It's gonna End soon , sooner than it started .
#include "bits/stdc++.h"
#define pb push_back
using ll = long long;
using namespace std;
#define endl "\n";
int no = 1;
void D(){
string s ;cin>>s;
string res;
int n = s.length();
int prev= s[0] -'0';
for(int i =0;i<prev;i++)res+='(';
res+=s[0];
for(int i =1; i<n;i++){
int curr = s[i] -'0';
ll diff = abs(prev-curr);
if(prev> curr){
while(diff--) res+=')';
}
else{
while(diff--) res+='(';
}
res+=s[i];
prev =curr;
}
while(prev--) res+=')';
cout<<"Case #"<<no<<": "<<res<<endl;
no++;
}
int main(int argc, char const *argv[])
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(0);
cout<<fixed;
ll n , m,k ,pt(0),ct(0) ,x,y;
ll t =1;
cin>>t;
while(t--){
D();
}
}