Submission #494912

# Submission time Handle Problem Language Result Execution time Memory
494912 2021-12-17T12:57:38 Z kappa Crtanje (COCI20_crtanje) C++14
50 / 50
1 ms 304 KB
#include <bits/stdc++.h>

using namespace std;

int n, up = 99, down = 99, curr = 99;

char d[105], matrix[205][105];

int main(){
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }

    memset(matrix, '.', sizeof(matrix));

    switch (d[0])
    {
    case '+':
        matrix[curr][0] = '/';
        curr--;
        break;

    case '-':
        matrix[curr][0] = '\\';
        curr++;
        break;
    
    default:
        matrix[curr][0] = '_';
        break;
    }

    for (int i = 1; i < n; i++)
    {
        switch (d[i])
        {
        case '+':
            if(d[i - 1] == '+'){
                matrix[curr][i] = '/';
                up = min(up, curr);
                curr--;
            }else if(d[i - 1] == '-'){
                matrix[curr - 1][i] = '/';
                up = min(up, curr);
                curr -= 2;
            }else{
                matrix[curr][i] = '/';
                up = min(up, curr);
                curr--;
            }
            break;

        case '-':
            if(d[i - 1] == '-'){
                matrix[curr][i] = '\\';
                down = max(down, curr);
                curr++;
            }else if(d[i - 1] == '+'){
                matrix[curr + 1][i] = '\\';
                down = max(down, curr);
                curr += 2;
            }else{
                matrix[curr + 1][i] = '\\';
                down = max(down, curr);
                curr += 2;
            }
            break;
        
        default:
            if(d[i - 1] == '-'){
                curr--;
                matrix[curr][i] = '_';
            }else if(d[i - 1] == '+'){
                //curr++;
                matrix[curr][i] = '_';
                up = min(up, curr);
            }else{
                matrix[curr][i] = '_';
            }
            break;
        }
    }

    for (int i = up; i <= down; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << matrix[i][j];
        }

        cout << "\n";
    }
    
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct