답안 #374328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374328 2021-03-07T07:47:47 Z topovik Crtanje (COCI20_crtanje) C++14
50 / 50
1 ms 364 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll N = 1e6 + 100;
const ll oo = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int mx = -1, mn = 0, lv = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '=')
        {
            mn = min(mn, lv);
            mx = max(mx, lv);
        }
        if (s[i] == '-')
        {
            lv--;
            mn = min(mn, lv);
        }
        if (s[i] == '+')
        {
            mx = max(mx, lv);
            lv++;
        }
    }
    mx += (-mn);
    char ans[mx + 1][n];
    for (int i = 0; i <= mx; i++)
        for (int j = 0; j < n; j++) ans[i][j] = '.';
    lv = -mn;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '=')
        {
            ans[lv][i] = '_';
        }
        if (s[i] == '+')
        {
            ans[lv][i] = '/';
            lv++;
        }
        if (s[i] == '-')
        {
            lv--;
            ans[lv][i] = '\\';
        }
    }
    for (int i = mx; i >= 0; i--)
    {
        for (int j = 0; j < n; j++) cout << ans[i][j];
        cout << endl;
    }
}
# 결과 실행 시간 메모리 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 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct