답안 #337377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337377 2020-12-20T10:40:52 Z Jarif_Rahman Crtanje (COCI20_crtanje) C++17
50 / 50
1 ms 384 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; str s;
    cin >> n >> s;
    ll cur = 0, mn = 0, mx = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '+') cur++;
        if(s[i] == '-') cur--;
        mn = min(mn, cur);
        mx = max(mx, cur);
    }
    vector<str> v(mx-mn+1, str(n, '.'));
    int c = abs(mx);
    for(int i = 0; i < n; i++){
        if(s[i] == '+'){
            v[c][i] = '/';
            c--;
        }
        if(s[i] == '-'){
            c++;
            v[c][i] = '\\';
        }
        if(s[i] == '='){
            v[c][i] = '_';
        }
    }
    if(v[0] == str(n, '.')) v.erase(v.begin());
    for(str ss: v) cout << ss << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct