QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#614320#8935. Puzzle: Easy as Scrabbleticking_away#WA 0ms13800kbC++202.3kb2024-10-05 16:10:292024-10-05 16:10:29

Judging History

你现在查看的是最新测评结果

  • [2024-10-05 16:10:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:13800kb
  • [2024-10-05 16:10:29]
  • 提交

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;
}

詳細信息

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}"