QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642006#8935. Puzzle: Easy as Scrabbleucup-team3215WA 0ms3812kbC++233.2kb2024-10-15 08:38:242024-10-15 08:38:24

Judging History

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

  • [2024-10-15 08:38:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3812kb
  • [2024-10-15 08:38:24]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<char> L(n), R(n), U(m), D(m);
    vector<vector<char>> a(n, vector<char>(m));
    for (int i = 0; i <= n + 1; ++i) {
        for (int j = 0; j <= m + 1; ++j) {
            char c;
            cin >> c;
            if (i >= 1 && i <= n && j >= 1 && j <= m) {
                a[i - 1][j - 1] = c;
            } else if (!i) {
                if (j >= 1 && j <= m)U[j - 1] = c == '.' ? 0 : c;
            } else if (i == n + 1) {
                if (j >= 1 && j <= m)D[j - 1] = c == '.' ? 0 : c;
            } else if (!j) {
                if (i >= 1 && i <= n)L[i - 1] = c == '.' ? 0 : c;
            } else if (j == m + 1) {
                if (i >= 1 && i <= n)R[i - 1] = c == '.' ? 0 : c;
            }
        }
    }
    auto letthemend = [] {
        cout << "NO\n";
        exit(0);
    };
    vector<vector<char>> res(n, vector<char>(m, '.'));
    vector<int> l(n), r(n, m - 1), u(m, -1), d(m, n);
    for (int i = 0; i < n; ++i) {
        if (L[i])while (l[i] < m && a[i][l[i]] == 'x')++l[i];
        else l[i] = -1;
        if (R[i])while (r[i] >= 0 && a[i][r[i]] == 'x')--r[i];
        else r[i] = m;
    }
    for (int j = 0; j < m; ++j) {
        if (U[j]) {
            for (u[j] = 0; u[j] < n; ++u[j]) {
                if (a[u[j]][j] == 'x')continue;
                if (l[u[j]] < j || L[u[j]] == U[j] || !L[u[j]])break;
                ++l[u[j]];
                while (l[u[j]] < m && a[u[j]][l[u[j]]] == 'x')++l[u[j]];
            }
        }
        if (D[j]) {
            for (d[j] = n - 1; ~d[j]; --d[j]) {
                if (a[d[j]][j] == 'x')continue;
                if (l[d[j]] < j || L[d[j]] == D[j] || !L[d[j]])break;
                ++l[d[j]];
                while (l[d[j]] < m && a[d[j]][l[d[j]]] == 'x')++l[d[j]];
            }
        }
        if (u[j] > d[j] || (u[j] == d[j] && U[j] != D[j]))letthemend();
    }
    for (int j = m - 1; ~j; --j) {
        if (U[j]) {
            for (; u[j] < n; ++u[j]) {
                if (a[u[j]][j] == 'x')continue;
                if (r[u[j]] > j || R[u[j]] == U[j] || !R[u[j]])break;
                --r[u[j]];
                while (r[u[j]] >= 0 && a[u[j]][r[u[j]]] == 'x')--r[u[j]];
            }
        }
        if (D[j]) {
            for (d[j] = n - 1; ~d[j]; --d[j]) {
                if (a[d[j]][j] == 'x')continue;
                if (l[d[j]] < j || L[d[j]] == D[j] || !L[d[j]])break;
                --r[d[j]];
                while (r[d[j]] >= 0 && a[d[j]][r[d[j]]] == 'x')--r[d[j]];
            }
        }
        if (u[j] > d[j] || (u[j] == d[j] && U[j] != D[j]))letthemend();
    }
    for (int i = 0; i < n; ++i) {
        if (l[i] > r[i] || (l[i] == r[i] && L[i] != R[i]))letthemend();
    }
    for (int i = 0; i < n; ++i) {
        if (L[i])res[i][l[i]] = L[i];
        if (R[i])res[i][r[i]] = R[i];
    }
    for (int j = 0; j < m; ++j) {
        if (U[j])res[u[j]][j] = U[j];
        if (D[j])res[d[j]][j] = D[j];
    }
    cout << "YES\n";
    for (auto &i: res) {
        for (auto &j: i)cout << j;
        cout << "\n";
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

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: 3500kb

input:

1 2
....
Nx..
..O.

output:

NO

result:

ok Correct.

Test #3:

score: 0
Accepted
time: 0ms
memory: 3812kb

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: 3556kb

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:

YES
.AZEMIEK..
B.......U.
K.......T.
A........J
.H.......B
Q.......W.
S........W
S.O......W
QK...D..Z.
...II...R.

result:

wrong answer Row 8 right clue not satisfied.