QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#808802 | #8935. Puzzle: Easy as Scrabble | Noobie_99 | WA | 1ms | 3568kb | C++20 | 1.6kb | 2024-12-11 04:37:25 | 2024-12-11 04:37:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) ::begin(x), ::end(x)
void _d(auto... x) { ((cerr << ' ' << x), ...) << endl; }
#define debug(x...) cerr << "["#x"]:", _d(x)
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<string> a(n+2);
for (string& e : a) cin >> e;
vector b = vector(n, vector(m, vector<array<int, 3>>()));
for (int i=0; i<n; i++) for (int j=0; j<m; j++) {
if (a[i+1][j+1] == 'x') b[i][j].push_back({0, 0, -1});
}
queue<array<int, 5>> q;
for (int i=0; i<m; i++) if (a[0][i+1] != '.') {
q.push({0, i, 1, 0, a[0][i+1]});
}
for (int i=0; i<m; i++) if (a[n+1][i+1] != '.') {
q.push({n-1, i, -1, 0, a[n+1][i+1]});
}
for (int i=0; i<n; i++) if (a[i+1][0] != '.') {
q.push({i, 0, 0, 1, a[i+1][0]});
}
for (int i=0; i<n; i++) if (a[i+1][m+1] != '.') {
q.push({i, m-1, 0, -1, a[i+1][m+1]});
}
vector<string> ans(n, string(m, '.'));
while (!q.empty()) {
auto [x, y, ddx, ddy, cc] = q.front();
q.pop();
b[x][y].push_back({ddx, ddy, cc});
if (ssize(b[x][y]) == 2) {
for (auto [dx, dy, c] : b[x][y]) if (c != -1) {
int tx = x + dx, ty = y + dy;
if (tx < 0 || tx >= n || ty < 0 || ty >= m) {
cout << "NO\n";
return 0;
}
q.push({tx, ty, dx, dy, c});
}
} else {
ans[x][y] = cc;
}
}
cout << "YES\n";
for (string& e : ans) cout << e << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3560kb
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: 3556kb
input:
1 2 .... Nx.. ..O.
output:
NO
result:
ok Correct.
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3568kb
input:
5 5 .U.N.X. U....xX Ox....X M...xxN Vx....S Ix.x..X ..IBHX.
output:
NO
result:
wrong answer Jury has answer but participant has not.