답안 #473878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473878 2021-09-16T11:10:40 Z Ahmed57 Crtanje (COCI20_crtanje) C++14
30 / 50
1 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
string s = "\\";
int main(){
    int n;
    cin>>n;
    char arr[n];
    int r=0,l=0,w=0;
    for(int i = 0;i<n;i++){
        cin>>arr[i];
        if(arr[i]=='-')r--;
        if(arr[i]=='+')r++;
        if(r>=0)l=max(l,r);
        if(r<0)w=max(w,abs(r));
    }
    int    ma = l+w;
    char gr[ma][n];
    memset(gr,'.',sizeof gr);
    int x = l-1, y = 0;if(l==0)x=0;
    for(int i = 0;i<n;i++){
        if(arr[i]=='+'){
            gr[x][y] = '/';
            if(i<n-1&&arr[i+1]=='-'){
                y++;
            }else{
                x--;y++;
            }
        }else if(arr[i]=='-'){
            gr[x][y] = s[0];
            if(i<n-1&&(arr[i+1]=='+'||arr[i+1]=='=')){
                y++;
            }else{
                x++;y++;
            }
        }else{
            gr[x][y] = '_';
            y++;
        }
    }
    for(int i = 0;i<ma;i++){
        for(int j = 0;j<n;j++){
            cout<<gr[i][j];
        }
        cout<<"\n";
    }
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Correct 1 ms 204 KB Output is correct