QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#418971 | #6748. Spin the Wheel | Dog_E# | WA | 1ms | 5560kb | C++20 | 2.1kb | 2024-05-23 16:44:09 | 2024-05-23 16:44:09 |
Judging History
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