QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641817#6746. Merge the RectanglesNyansWA 10ms21284kbC++141.3kb2024-10-15 00:22:022024-10-15 00:22:03

Judging History

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

  • [2024-10-15 00:22:03]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:21284kb
  • [2024-10-15 00:22:02]
  • 提交

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];
        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[i][xx] - pre2[i][x];
        if (t == xx - x) {
            return (check(x, y, xx, i) && check(x, i, xx, yy));
        } else {
            tmp += t;
        }
    }

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

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

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

    for (int i = 1; i < m; ++i) {
        std::string s; std::cin >> s;
        for (int j = 0; j < n; ++j) {
            pre2[i][j + 1] = pre2[i][j] + s[j] - '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: 3572kb

input:

3 4
0000
0111
101
101
110

output:

YES

result:

ok answer is YES

Test #2:

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

input:

3 3
110
011
01
11
10

output:

NO

result:

ok answer is NO

Test #3:

score: -100
Wrong Answer
time: 10ms
memory: 21284kb

input:

1500 1500
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

NO

result:

wrong answer expected YES, found NO