結果

問題 No.3685 ワロングアンサーやんけ!
コンテスト
ユーザー のらら
提出日時 2026-09-05 14:46:50
言語 C++23
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,502 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,818 ms
コンパイル使用メモリ 265,128 KB
実行使用メモリ 9,796 KB
最終ジャッジ日時 2026-09-05 14:47:01
合計ジャッジ時間 5,835 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
//#define endl "\n";
int main(){
    ll Q;
    cin >> Q;
    for(int q = 1; q <= Q; q++){
        string R, S;
        cin >> R;
        cin >> S;
        ll K;
        cin >> K;
        ll w = 0;
        for(ll i = 0; (ll)i < R.size(); i++){
            if(R[i] == 'W') w++;
        }
        if(S == "Warong"){
            //最初のK文字がA
            for(ll i = 0; i < K; i++) R[i] = 'A';
            if(w == 0){
                ll cnt = 0;
                for(ll i = 0; i < (ll)R.size(); i++) if(R[i] == '?') cnt++;
                if(cnt == 1){
                    //?が1個だけならW確定
                    for(ll i = 0; i < (ll)R.size(); i++) if(R[i] == '?') R[i] = 'W';
                }
                cout << R << endl;
            }else{
                cout << R << endl;
            }
        }else{
            //K文字Aが続かなければよい
            ll cnt = 0, cntw = 0;
            for(ll i = 0; i < min(K, (ll)R.size()); i++){
                if(R[i] == '?') cnt++;
                if(R[i] == 'W') cntw++;
            }
            if(cnt == 1 && cntw == 0){
                //?が1個だけならW確定
                for(ll i = 0; i < min(K, (ll)R.size()); i++) if(R[i] == '?') R[i] = 'W';
                cout << R << endl;
            }else{
                cout << R << endl;
            }
        }
    }
    return 0;
}
0