Submission #489669

#TimeUsernameProblemLanguageResultExecution timeMemory
489669fuad27Crtanje (COCI20_crtanje)C++17
50 / 50
1 ms276 KiB
#include<bits/stdc++.h> using namespace std; int k(char c) { if(c == '/')return 1; if(c == '\\')return -1; return 0; } int main () { int n; cin >> n; string s; cin >> s; int MAX = 0, MIN = 0, curr = 0; for(char i:s) { if(i == '+')curr++; else if(i == '-')curr--; else { MAX = max(MAX, curr+1); } MAX = max(MAX, curr); MIN = min(MIN, curr); } char arr[MAX-MIN][n]; curr = MAX; char c = '.'; for(int i = 0;i<n;i++) { if(s[i] == '+')curr--; if(s[i] == '+')c = '/'; else if(s[i] == '-')c='\\'; else {c='_';curr--;} for(int j = 0;j<MAX-MIN;j++) { if(j == curr)arr[j][i] = c; else arr[j][i] = '.'; } if(s[i] == '-')curr++; else if(s[i] == '=')curr++; } for(int i = 0;i<MAX-MIN;i++) { for(int j = 0;j<n;j++) { cout << arr[i][j]; } cout << endl; } if(MAX-MIN == 0) { for(int i = 0;i<n;i++)cout<<'-'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...