QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#569457#8935. Puzzle: Easy as Scrabbleucup-team3519WA 0ms3880kbC++202.4kb2024-09-16 23:08:532024-09-16 23:08:53

Judging History

This is the latest submission verdict.

  • [2024-09-16 23:08:53]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3880kb
  • [2024-09-16 23:08:53]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define V vector
#define all0(x) (x).begin(),(x).end()
#define all1(x) (x).begin()+1,(x).end()
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define cin std::cin
#define cout std::cout
typedef long long LL;
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;

//const int MN = 2e5 + 20;
const int INF = 2e9 + 1000;//INF
const LL INFLL = 8e18 + 1000;//INF long long 
mt19937 mrand(chrono::steady_clock().now().time_since_epoch().count());
//模板区域~~~~~~~

//模板结束~~~~~~~

void solve() {
    int n, m; cin >> n >> m;
    string up, down;
    V<string> vs(n + 1);
    cin >> up;
    for(int i = 1; i <= n; i++) cin >> vs[i];
    cin >> down;
    auto ok = [&](char c, char lim) -> bool {
        if(c == lim) return 1;
        if(lim == '.') return 1;
        return 0;  
    };
    for(int i = 1; i <= n; i++) {
        int l = 1, r = m;
        if(vs[i][0] != '.') {
            while(l <= m && (l == 1 || !ok(vs[i][0], up[l - 1]) || vs[i][l - 1] == 'x')) l++;
            if(!ok(vs[i][0], up[l - 1]) || vs[i][l - 1] == 'x') {
                cout << "NO" << endl;
                return;
            }
        }
        if(vs[i].back() != '.') {
            while(r >= 1 && (r == m || !ok(vs[i].back(), up[r + 1]) || vs[i][r + 1] == 'x')) r--;
            if(!ok(vs[i].back(), up[r + 1]) || vs[i][r + 1] == 'x') {
                cout << "NO" << endl;
                return;
            }
        }
        vs[i][l - 1] = vs[i][0];
        vs[i][r + 1] = vs[i][m + 1];
        for(int j = l; j <= r; j++) {
            if(vs[i][j] == 'x') continue;
            if(up[j] != '.') vs[i][j] = up[j], up[j] = '.';
            else vs[i][j] = down[j];
        }
    }

    for(int i = 1; i <= m; i++) {
        int lst = '.';
        for(int j = 1; j <= n; j++) if(vs[j][i] != '.' && vs[j][i] != 'x') lst = vs[j][i];
        if(!ok(lst, down[i])) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) cout << (vs[i][j] == 'x' ? '.' : vs[i][j]);
        cout << endl;
    }
}

int32_t main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t=1;
    //cin >> t;
    while (t--) 
    solve();
}

详细

Test #1:

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

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

input:

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

output:

NO

result:

ok Correct.

Test #3:

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

input:

5 5
.U.N.X.
U....xX
Ox....X
M...xxN
Vx....S
Ix.x..X
..IBHX.

output:

YES
UINX.
.OBHX
.MN..
.VBS.
.I.HX

result:

ok Correct.

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3840kb

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.