結果

問題 No.3685 ワロングアンサーやんけ!
コンテスト
ユーザー Mikan04y
提出日時 2026-07-10 19:06:49
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,535 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,258 ms
コンパイル使用メモリ 354,784 KB
実行使用メモリ 9,788 KB
最終ジャッジ日時 2026-09-05 12:33:35
合計ジャッジ時間 5,610 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 17 RE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define all(x) x.begin(), x.end()

void solve() {
    int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;

    string ans = S;

    // Warong
    if (T.compare("Warong") == 0) {
        rep(i, 0, M) {
            ans[i] = 'A';
        }
        int wcnt = 0, ncnt = 0;
        rep(i, M, N) {
            wcnt += (S[i] == 'W' ? 1 : 0);
            ncnt += (S[i] == '?' ? 1 : 0);
        }
        if (wcnt == 0 && ncnt == 1) {
            rep(i, M, N) {
                if (S[i] == '?') ans[i] = 'W';
            }
        }
        cout << ans << '\n';
        return;
    }

    // NotWarong
    int acnt = 0, wcnt1 = 0, wcnt2 = 0, ncnt1 = 0, ncnt2 = 0;
    rep(i, 0, M) {
        acnt += (S[i] == 'A' ? 1 : 0);
        wcnt1 += (S[i] == 'W' ? 1 : 0);
        ncnt1 += (S[i] == '?' ? 1 : 0);
    }
    rep(i, M, N) {
        wcnt2 += (S[i] == 'W' ? 1 : 0);
        ncnt2 += (S[i] == '?' ? 1 : 0);
    }

    // Sample all 'A'
    if (acnt == M) {
        rep(i, 0, N) {
            ans[i] = 'A';
        }
        cout << ans << '\n';
        return;
    }

    // WA
    if (wcnt1 == 0 && wcnt2 > 0 && ncnt1 == 1 && ncnt2 == 0) {
        rep(i, M, N) {
            if (S[i] == '?') ans[i] = 'W';
        }
    }

    cout << ans << '\n';
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
}
0