QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#614248 | #8935. Puzzle: Easy as Scrabble | nekoyellow | WA | 0ms | 3772kb | C++20 | 2.1kb | 2024-10-05 16:00:32 | 2024-10-05 16:00:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<string> g(n+2);
for (auto &s: g) cin >> s;
bool bad = false;
for (int i = 1, j; i <= n; i++) {
if (g[i][0] == '.') continue;
for (j = 1; j <= m; j++) {
if (g[i][j] == g[i][0]) break;
if (g[i][j] != 'x' && g[i][j] != '.') bad = true;
if (g[i][j] == '.') {
g[i][j] = g[i][0];
break;
}
}
if (j == m+1) {
bad = true;
}
}
for (int i = 1, j; i <= n; i++) {
if (g[i][m+1] == '.') continue;
for (j = m; j > 0; j--) {
if (g[i][j] == g[i][m+1]) break;
if (g[i][j] != 'x' && g[i][j] != '.') bad = true;
if (g[i][j] == '.') {
g[i][j] = g[i][m+1];
break;
}
}
if (j == 0) {
bad = true;
}
}
for (int j = 1, i; j <= m; j++) {
if (g[0][j] == '.') continue;
for (i = 1; i <= n; i++) {
if (g[i][j] == g[0][j]) break;
if (g[i][j] != 'x' && g[i][j] != '.') bad = true;
if (g[i][j] == '.') {
g[i][j] = g[0][j];
break;
}
}
if (i == n+1) {
bad = true;
}
}
for (int j = 1, i; j <= m; j++) {
if (g[n+1][j] == '.') continue;
for (i = n; i > 0; i--) {
if (g[i][j] == g[n+1][j]) break;
if (g[i][j] != 'x' && g[i][j] != '.') bad = true;
if (g[i][j] == '.') {
g[i][j] = g[n+1][j];
break;
}
}
if (i == 0) {
bad = true;
}
}
if (bad) {
cout << "NO\n";
return 0;
}
cout << "YES\n";
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cout << (g[i][j] == 'x' ? '.' : g[i][j]);
}
cout << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
5 5 .CBA... ....x.. ..x...C A.....B B..x..A C...... .......
output:
YES CBA.. ....C A...B B...A C....
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
1 2 .... Nx.. ..O.
output:
NO
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
5 5 .U.N.X. U....xX Ox....X M...xxN Vx....S Ix.x..X ..IBHX.
output:
YES U.NX. .O..X M.N.. .VB.S .I.HX
result:
ok Correct.
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3600kb
input:
10 10 .BAZEMIEKUJ. A..........K B..x.x.x..x. K.........xT A.x..x.....J Hx....x....B Q..x....x.xW S...x......W S...x.xxx..Z ...x......xZ I..x..x.x.xR .QKO.ID..RW.
output:
NO
result:
wrong answer Jury has answer but participant has not.