답안 #374265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374265 2021-03-07T05:46:54 Z kartel Crtanje (COCI20_crtanje) C++14
20 / 50
1 ms 364 KB
#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
//#include <time.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
//#define M ll(1e9 + 7)
#define M ll(998244353)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define arr_all(x, n) (x + 1), (x + 1 + n)
#define vi vector<int>
#define eps (ld)1e-9
using namespace std;
typedef long long ll;
//using namespace __gnu_pbds;
//typedef tree <ll, null_type, less_equal <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef double ld;
typedef unsigned long long ull;
typedef short int si;

string s;
int n;
char a[205][205];

int main()
{
//    mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());;
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	in("toys.in");
//	out("toys.out");
//    in("input.txt");
//    out("output.txt");
//    cerr.precision(9); cerr << fixed;

//    clock_t tStart = clock();

    cin >> n >> s;

    int min_b = 0;
    int max_b = 0;
    int b = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == '-') {
            b--;
        }
        else {
            if (s[i] == '+') {
                b++;
            }
        }

        min_b = min(min_b, b);
        max_b = max(max_b, b);
    }

    int x = max_b - min_b;
    int y = 0;
    int l = -1;
    int r = -1;

    for (int i = 0; i < n; i++) {
        if (s[i] == '+') {
            if (r == -1) {
                l = x; r = x;
            }
            l = min(l, x);
            a[x][y] = '/';
            x--;
        }
        else {
            if (s[i] == '-') {
                x++;
                if (l == -1) {
                    l = r = x;
                }
                r = max(r, x);
                a[x][y] = '\\';
            }
            else {
                a[x][y] = '_';
            }
        }
        y++;
    }

    for (int i = l; i <= r; i++, cout << el) {
        for (int j = 0; j < n; j++) {
            if (a[i][j] != '/' && a[i][j] != '\'' && a[i][j] != '_') {
                a[i][j] = '.';
            }

            cout << a[i][j];
        }
    }
}


/*

7
4 6 7 2 3 1 5
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Incorrect 1 ms 364 KB Output isn't correct