QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528523 | #6396. Puzzle: Kusabi | hnust_xiaoqi# | WA | 0ms | 3736kb | C++20 | 2.7kb | 2024-08-23 15:46:46 | 2024-08-23 15:46:46 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
const int N = 150;
typedef long long LL;
typedef pair<int, int> PII;
int n, m;
char a[N][N], b[N][N];
void solve() {
cin >> n >> m;
n = n * 2 - 1; m = m * 2 - 1;
memset(a, '.', sizeof a);
for(int i = 6; i <= n + 5; i++) {
for(int j = 6; j <= m + 5; j++) {
cin >> a[i][j];
if(a[i][j] == '.') a[i][j] = '#';
b[i][j] = a[i][j];
}
}
// for(int i = 5; i <= n + 6; i++) {
// for(int j = 5; j <= m + 6; j++) cout << a[i][j];
// cout << endl;
// }
for(int i = 6; i <= n + 5; i++) {
for(int j = 6; j <= m + 5; j++) {
if(a[i][j] == '2' && (a[i][j + 2] == '4' || a[i][j + 2] == '2')) a[i][j + 1] = '.', a[i][j]++, a[i][j + 2]++;
if(a[i][j] == '4' && (a[i][j + 2] == '4' || a[i][j + 2] == '7')) a[i][j + 1] = '.', a[i][j]++, a[i][j + 2]++;
if(a[i][j] == '7' && (a[i][j + 2] == '7' || a[i][j + 2] == '4')) a[i][j + 1] = '.', a[i][j]++, a[i][j + 2]++;
}
}
for(int i = 6; i <= n + 5; i++) {
for(int j = 6; j <= m + 5; j++) {
if(a[j][i] == '2' && (a[j + 2][i] == '4' || a[j + 2][i] == '2')) a[j + 1][i] = '.';
if(a[j][i] == '4' && (a[j + 2][i] == '4' || a[j + 2][i] == '7')) a[j + 1][i] = '.';
if(a[j][i] == '7' && (a[j + 2][i] == '7' || a[j + 2][i] == '4')) a[j + 1][i] = '.';
}
}
// cout << endl;
// for(int i = 5; i <= n + 6; i++) {
// for(int j = 5; j <= m + 6; j++) cout << a[i][j];
// cout << endl;
// }
for(int i = 6; i <= n + 5; i++) {
for(int j = 6; j <= m + 5; j++) {
if(a[i][j] == '#') {
if(a[i - 1][j] != '#' && a[i + 1][j] != '#' && a[i][j - 1] != '#' && a[i][j + 1] != '#') {
cout << "NO\n";
return ;
}
}
if(a[i][j] == '.') {
if(a[i - 1][j] == '#' && a[i + 1][j] == '#') {
cout << "NO\n";
return ;
}
if(a[i][j - 1] == '#' && a[i][j + 1] == '#') {
cout << "NO\n";
return ;
}
}
}
}
for(int i = 6; i <= n + 5; i++) {
for(int j = 6; j <= m + 5; j++) {
int x = b[i][j] - '0';
int sum = 0;
if(x >= 0 && x <= 9) {
for(int k = -1; k <= 1; k++) {
for(int l = -1; l <= 1; l++) {
int xx = i + k, yy = j + l;
if(a[xx][yy] == '#') {
sum++;
}
}
}
if(sum != x) {
cout << "NO\n";
return ;
}
}
}
}
cout << "YES\n";
for(int i = 6; i <= n + 5; i++) {
for(int j = 6; j <= m + 5; j++) {
if(a[i][j] >= '0' && a[i][j] <= '9') cout << b[i][j];
else cout << a[i][j];
}
cout << endl;
}
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(0);
cout.tie(0);
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: 0ms
memory: 3736kb
input:
8 2 1 - 3 1 - 4 2 Tong 5 2 Tong 6 3 Duan 7 3 - 8 7 Chang
output:
NO
result:
wrong answer Jury has answer but participant has not.