QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#641822 | #6746. Merge the Rectangles | Nyans | WA | 44ms | 21412kb | C++14 | 1.3kb | 2024-10-15 00:33:29 | 2024-10-15 00:33:29 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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