제출 #1177546

#제출 시각아이디문제언어결과실행 시간메모리
1177546Gadir_2880Crtanje (COCI20_crtanje)C++20
50 / 50
1 ms1352 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N2 = 1005;
char ans[N2][N2];


int x = 100, y = 100;
int xl = 100, xr = 100;
int yl = 100, yr = 100;

void ch(){
  xl = min(xl, x);
  xr = max(xr, x);
  yl = min(yl, y);
  yr = max(yr, y);
}

void solve(){
  int n; cin >> n;
  string s; cin >> s;
  s = '%' + s;
  
  for(int i=0; i<N2; i++){
    for(int j=0; j<N2; j++){
      ans[i][j] = '.';
    }
  }
  
  
  
  
  for(int i=1; i<=n; i++){
    ch();
    
    if(s[i] == '='){
      if(s[i-1] == '+'){
        x--, y++;
      } else if(s[i-1] == '='){
        y++;
      } else if(s[i-1] == '-'){
        y++;
      }
      
      ans[x][y] = '_';
      continue;
    }
    
    if(s[i] == '+'){
      if(s[i-1] == '+'){
        x--, y++;
      } else if(s[i-1] == '='){
        y++;
      } else if(s[i-1] == '-'){
        y++;
      }
      
      ans[x][y] = '/';
      continue;
    }
    
    
    if(s[i] == '-'){
      if(s[i-1] == '+'){
        y++;
      } else if(s[i-1] == '='){
        x++, y++;
      } else if(s[i-1] == '-'){
        y++, x++;
      }
      
      ans[x][y] = '\\';
      continue;
    }
  }
  
  // cout << xl << " ";
  // cout << xr << " ";
  // cout << yl << " ";
  // cout << yr << " ";
  
  
  
  ch();
  for(int i=xl; i<=xr; i++){
    for(int j=yl; j<=yr; j++){
      cout << ans[i][j];
    }
    cout << endl;
  }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
    int t = 1;
    while(t--){
      solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...