답안 #854435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854435 2023-09-27T16:22:37 Z vjudge1 Crtanje (COCI20_crtanje) C++17
40 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
const int N = 2e5+1;

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int mini = 0;
	int maxi = 0;
	int cur = 0;
	for (int i=0;i<n;i++) {
		if (s[i] == '+') cur++;
		else if (s[i] == '-') cur--;
		maxi = max(maxi,cur);
		mini = min(mini,cur);
	}	
	int m = n;
	n = maxi-mini;
	vector<vector<char>> grid(n+5,vector<char>(m+5,'.'));
	cur = n-(1-mini)+1;
	for (int i=0;i<m;i++) {
		if (s[i] == '+') {
			grid[cur][i+1] = '/';
			cur--;
		}
		else if (s[i] == '-') {			
			cur++;
			grid[cur][i+1] = '\\';
		}
		else {
			grid[cur][i+1] = '_';
		}
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) cout << grid[i][j];
		cout << endl;
	}
}     
                                
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Correct 1 ms 348 KB Output is correct