#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
#define lim 200005
using namespace std;
void solve(){
int n; cin >> n;
string s; cin >> s;
int mini=0, maxi=0, cur=0;
for(int i=0; i<n; i++){
char c=s[i];
if(i!=n-1){
if(s[i]=='+' && s[i+1]!='-') cur--;
if(s[i]=='-' && s[i+1]=='-') cur++;
}
mini = max(-cur, mini);
maxi = max(cur, maxi);
}
cerr << mini spc maxi << endl;
char arr[mini+maxi+1][n];
for(int i=0; i<mini+maxi+1; i++) for(int j=0; j<n; j++) arr[i][j]='.';
cur=mini;
for(int i=0; i<n; i++){
if(s[i]=='='){
arr[cur][i]='_';
if(i!=n-1 && s[i+1]=='-')cur++;
}
else if(s[i]=='+'){
arr[cur][i]='/';
if(i!=n-1 && s[i+1]!='-')cur--;
}
else{
arr[cur][i]='\\';
if(i!=n-1 && s[i+1]=='-')cur++;
}
}
for(int i=0; i<mini+maxi+1; i++){
for(int j=0; j<n; j++) cout << arr[i][j];
cout << endl;
}
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
Compilation message
crtanje.cpp: In function 'void solve()':
crtanje.cpp:32:14: warning: unused variable 'c' [-Wunused-variable]
32 | char c=s[i];
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |