QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#614320 | #8935. Puzzle: Easy as Scrabble | ticking_away# | WA | 0ms | 13800kb | C++20 | 2.3kb | 2024-10-05 16:10:29 | 2024-10-05 16:10:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)
/**
____ ___ _____
/ ___| _ _ / _ \___ /
\___ \| | | | | | ||_ \
___) | |_| | |_| |__) |
|____/ \__, |\___/____/
|___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
for (auto &i : v)
in >> i;
return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
for (auto &i : v)
out << i << " ";
return out;
}
bool _output = 0;
int n, m;
char s[1010][1010];
vector<pii> res[1010][1010];
queue<pii> q;
int f[4][1010][1010];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
bool check(int x, int y)
{
return x >= 1 && x <= n && y >= 1 && y <= m;
}
void make(int x, int y, int dir, int c)
{
while (s[x][y] == 'x' && check(x, y))
x += dx[dir], y += dy[dir];
if (!check(x, y))
{
cout << "NO" << endl;
exit(0);
}
f[dir][x][y] = c;
if (s[x][y] != '.' && s[x][y] != c)
{
s[x][y] = 'x';
q.emplace(x, y);
}
else
s[x][y] = c;
}
void solve()
{
cin >> n >> m;
fr(i, 0, n + 1)
{
fr(j, 0, m - 1) cin >> s[i][j];
}
fr(j, 1, m) if (s[0][j] != '.') make(1, j, 0, s[0][j]);
fr(j, 1, m) if (s[n + 1][j] != '.') make(n, j, 1, s[n + 1][j]);
fr(j, 1, n) if (s[j][0] != '.') make(j, 1, 2, s[j][0]);
fr(j, 1, n) if (s[j][m + 1] != '.') make(j, m, 3, s[j][m + 1]);
while (q.size())
{
auto [x, y] = q.front();
q.pop();
fr(j, 0, 3) if (f[j][x][y]) make(x, y, j, s[x][y]);
}
cout << "YES" << endl;
fr(i, 1, n)
{
fr(j, 1, m)
{
if (s[i][j] == 'x')
cout << '.';
else
cout << s[i][j];
}
cout << endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int _ = 1;
if (_output)
cin >> _;
while (_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 13800kb
input:
5 5 .CBA... ....x.. ..x...C A.....B B..x..A C...... .......
output:
YES CBA.
result:
wrong answer Token parameter [name=row] equals to "CBA.~", doesn't correspond to pattern "[A-Z.]{5}"