QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#222455#6398. Puzzle: Tapatselmegkh#Compile Error//C++171.7kb2023-10-21 17:17:072023-10-21 17:17:07

Judging History

你现在查看的是最新测评结果

  • [2023-10-21 17:17:07]
  • 评测
  • [2023-10-21 17:17:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
int n, m;
char a[100][100];
bool inside(int x, int y, int x1, int y1, int x2, int y2) {
    return x1 <= x && x <= x2 && y1 <= y && y <= y2;
}
int count(int x, int y) {
    int ans = 0;
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            if (x + i >= 0 && x + i < 2 * n - 1 && y + j >= 0 && y + j < 2 * m - 1 && a[i][j] == '#') {
                ans++;
            }
        }
    }
    return ans;
}
bool rec(int x1, int y1, int x2, int y2) {
    if (x1 < x2 && y1 < y2) {
        for (int i = y1 + 1; i <= y2 - 1; i++) {
            a[x1 + 1][i] = a[x2 - 1][i] = '#';
        }
        for (int i = x1 + 1; i <= x2 - 1; i++) {
            a[i][y1 + 1] = a[i][y2 - 1] = '#';
        }
    }
    vector<pair<int, int>> M, L, R;
    for (int i = y1; i <= y2; i += 2) {
        if (M.empty() || M.back() != {x1, i}) {
            M.eb(x1, i);
            i == y1 ? L.eb(-1, 1) : L.eb(i, y1 - 1);
            if (i == y2) {
                R.eb(-1, -1);
            } else {
                R.eb(i, y2 + 1);
            }
        }
    }
    return 1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < 2 * n - 1; i++) {
        for (int j = 0; j < 2 * m - 1; j++) {
            cin >> a[i][j];
        }
    }
    if (!rec(0, 0, 2 * n - 2, 2 * m - 2)) {
        cout << "NO";
    } else {
        cout << "YES\n";
        for (int i = 0; i < 2 * n - 1; i++) {
            for (int j = 0; j < 2 * m - 1; j++) {
                cout << a[i][j];
            }
            cout << "\n";
        }
    }
}

Details

answer.code: In function ‘bool rec(int, int, int, int)’:
answer.code:31:38: error: expected primary-expression before ‘{’ token
   31 |         if (M.empty() || M.back() != {x1, i}) {
      |                                      ^
answer.code:31:37: error: expected ‘)’ before ‘{’ token
   31 |         if (M.empty() || M.back() != {x1, i}) {
      |            ~                        ^~
      |                                     )