#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N=111;
int n,t[N];
string s;
main () {
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
cin>>n;
cin>>s;
s="@"+s;
int Tmax=0,Tmin=0;
for (int i=1; i<=n; i++) {
if (s[i]=='+')
t[i]=t[i-1]+1;
else
if (s[i]=='-')
t[i]=t[i-1]-1;
else
if (s[i]=='=')
t[i]=t[i-1];
Tmax=max(Tmax,t[i]);
Tmin=min(Tmin,t[i]);
}
int ans=0;
for (int i=Tmax; i>=Tmin; i--) {
for (int j=1; j<=n; j++) {
if (s[j]=='=' && s[j-1]=='-' && t[j]+1==i) cout<<"_",ans++;
else
if (s[j]=='=' && (j==1 || s[j-1]=='=' || s[j-1]=='+') && t[j]==i) cout<<"_",ans++;
else
if (s[j]=='+' && t[j]==i) cout<<"/",ans++;
else
if (s[j]=='-' && t[j]+1==i) cout<<char(92),ans++;
else cout<<".";
}
if (ans==n) break;
cout<<"\n";
}
}
Compilation message
crtanje.cpp:14:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
14 | main () {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |