제출 #1177103

#제출 시각아이디문제언어결과실행 시간메모리
1177103theagentbaraCrtanje (COCI20_crtanje)C++20
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define endl '\n'
#define all(v) v.begin(), v.end()

const long long sz = 2e5 + 5;
const long long inf = 1e18;
const long long mod = 1e9 + 9;

bool isbound(int i, int j, int m, int n) {
    return i >= 0 and j >= 0 and i < m and j < n;
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int m = 0, mx = 0, mn = inf, cur = 0;
    for (int i = 0; i < n; i++) {
      cur += (s[i] == '+');
      cur -= (s[i] == '-');
      mx = max(mx, cur); mn = min(mn, cur);
    }
    m = mx - mn;
    for (int k = 0; k < m; k++) {
      char a[m][n];
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
          a[i][j] = '.';
        }
      }
      bool ok = 1;
      if (s[0] == '+') a[k][0] = '/';
      else if (s[0] == '-') a[k][0] = '\';
      else a[k][0] = '-';
      int l = 1, i = k, j = 0;
      while (l < s.size() and isbound(i, j, m, n)) {
        if (s[l - 1] == '-') {
          if (s[l] == '-') {
            if (isbound(i + 1, j + 1, m, n)) { 
              i++; j++; a[i][j] = '\\'; 
            } else { 
              ok = 0; break; 
            } 
          } else if (s[l] == '+') {
            if (isbound(i, j + 1, m, n)) {
              j++; a[i][j] = '/';
            } else {
              ok = 0; break;
            }
          } else if (s[l] == '=') {
            if (isbound(i, j + 1, m, n)) {
              j++; a[i][j] = '-';
            } else {
              ok = 0; break;
            }
          }
        } else if (s[l - 1] == '+') {
          if (s[l] == '-') {
            if (isbound(i, j + 1, m, n)) { 
              j++; a[i][j] = '\\'; 
            } else { 
              ok = 0; break; 
            } 
          } else if (s[l] == '+') {
            if (isbound(i - 1, j + 1, m, n)) {
              i--; j++; a[i][j] = '/';
            } else {
              ok = 0; break;
            }
          } else if (s[l] == '=') {
            if (isbound(i, j + 1, m, n)) {
              j++; a[i][j] = '-';
            } else {
              ok = 0; break;
            }
          }
        } 
        else if (s[l - 1] == '=') {
          if (s[l] == '-') {
            if (isbound(i + 1, j + 1, m, n)) { 
              i++;j++; a[i][j] = '\\'; 
            } else { 
              ok = 0; break; 
            } 
          } else if (s[l] == '+') {
            if (isbound(i - 1, j + 1, m, n)) {
              i--;j++; a[i][j] = '/';
            } else {
              ok = 0; break;
            }
          } else if (s[l] == '=') {
            if (isbound(i, j + 1, m, n)) {
              j++; a[i][j] = '-';
            } else {
              ok = 0; break;
            }
          }
        }
      }
      //if (ok) {
        for (int i = 0; i < m; i++) {
          for (int j = 0; j < n; j++) {
            cout << a[i][j];
          }
          cout << endl;
        }
        //exit(0);
      //}
      cout << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(0);
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

crtanje.cpp:37:39: warning: missing terminating ' character
   37 |       else if (s[0] == '-') a[k][0] = '\';
      |                                       ^
crtanje.cpp:37:39: error: missing terminating ' character
   37 |       else if (s[0] == '-') a[k][0] = '\';
      |                                       ^~~~
crtanje.cpp: In function 'void solve()':
crtanje.cpp:38:7: error: expected primary-expression before 'else'
   38 |       else a[k][0] = '-';
      |       ^~~~