QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641822#6746. Merge the RectanglesNyansWA 44ms21412kbC++141.3kb2024-10-15 00:33:292024-10-15 00:33:29

Judging History

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

  • [2024-10-15 00:33:29]
  • 评测
  • 测评结果:WA
  • 用时:44ms
  • 内存:21412kb
  • [2024-10-15 00:33:29]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

int n, m, pre1[1510][1510], pre2[1510][1510];

bool check(int x, int y, int xx, int yy) {
    if (x == xx || y == yy) {
        return 1;
    }

    int tmp = 0;
    for (int i = x + 1; i < xx; ++i) {
        int t = pre1[i][yy] - pre1[i][y - 1];
        if (t == yy - y) {
            return (check(x, y, i, yy) && check(i, y, xx, yy));
        } else {
            tmp += t;
        }
    }
    for (int i = y + 1; i < yy; ++i) {
        int t = pre2[xx][i] - pre2[x][i];
        if (t == xx - x) {
            return (check(x, y, xx, i) && check(x, i, xx, yy));
        } else {
            tmp += t;
        }
    }

    return ((tmp > 0) ? 0 : 1);
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin >> n >> m;
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j <= m; ++j) {
            char c; std::cin >> c;
            pre1[i][j] += pre1[i][j - 1] + c - '0';
        }
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < m; ++j) {
            char c; std::cin >> c;
            pre2[i][j] += pre2[i - 1][j] + c - '0';
        }
    }

    if (check(0, 0, n, m)) {
        std::cout << "YES\n";
    } else {
        std::cout << "NO\n";
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

3 4
0000
0111
101
101
110

output:

YES

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

3 3
110
011
01
11
10

output:

NO

result:

ok answer is NO

Test #3:

score: 0
Accepted
time: 34ms
memory: 21344kb

input:

1500 1500
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

YES

result:

ok answer is YES

Test #4:

score: 0
Accepted
time: 33ms
memory: 21412kb

input:

1500 1500
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

YES

result:

ok answer is YES

Test #5:

score: 0
Accepted
time: 35ms
memory: 21372kb

input:

1500 1500
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

YES

result:

ok answer is YES

Test #6:

score: 0
Accepted
time: 38ms
memory: 21296kb

input:

1500 1500
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

YES

result:

ok answer is YES

Test #7:

score: -100
Wrong Answer
time: 44ms
memory: 21340kb

input:

1500 1500
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

YES

result:

wrong answer expected NO, found YES