QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#418971#6748. Spin the WheelDog_E#WA 1ms5560kbC++202.1kb2024-05-23 16:44:092024-05-23 16:44:09

Judging History

This is the latest submission verdict.

  • [2024-05-23 16:44:09]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5560kb
  • [2024-05-23 16:44:09]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

char n[1510][1510], m[1510][1510];

struct Matrix {
    int a, b, c, d;
};

bool dfs(Matrix x) {
    // cout << x.a << " " << x.b << " " << x.c << " " << x.d << endl;
    int line = -1;
    bool all_empty = true;
    // 横
    for (int i = x.a + 1; i < x.b; i++) {
        bool ok = true;
        for (int j = x.c; j < x.d; j++) {
            if (m[i][j] == '0') {
                ok = false;
                break;
            } else
                all_empty = false;
        }
        // cout << ok << endl;

        if (ok == true) {
            line = i;
            return dfs({x.a, line, x.c, x.d}) && dfs({line, x.b, x.c, x.d});
        }
    }
    if (all_empty == true)
        return true;

    line = -1;
    all_empty = true;
    // 竖
    for (int i = x.c + 1; i < x.d; i++) {
        bool ok = true;
        for (int j = x.a; j < x.b; j++) {
            if (n[j][i] == '0') {
                ok = false;
                break;
            } else
                all_empty = false;
        }
        if (ok == true) {
            line = i;
            return dfs({x.a, line, x.c, x.d}) && dfs({line, x.b, x.c, x.d});
        }
    }
    if (all_empty == true)
        return true;
    return false;
}

void solve() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < M; j++) {
            if (i == 0 || i == N)
                m[i][j] = '1';
            else
                cin >> m[i][j];
            // cout << m[i][j];
        }
        // cout << endl;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= M; j++) {
            if (j == 0 || j == M)
                n[i][j] = '1';
            else
                cin >> n[i][j];
        }
    }
    if (dfs({0, N, 0, M}) == true)
        cout << "YES\n";
    else
        cout << "NO\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    // get_inv();
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5560kb

input:

5
1 3 0 2 4

output:

YES

result:

wrong output format Expected integer, but "YES" found