Submission #494912

#TimeUsernameProblemLanguageResultExecution timeMemory
494912kappaCrtanje (COCI20_crtanje)C++14
50 / 50
1 ms304 KiB
#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 timeMemoryGrader output
Fetching results...