結果

問題 No.3685 ワロングアンサーやんけ!
コンテスト
ユーザー 紫前燈太
提出日時 2026-07-21 22:38:11
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 174 ms / 2,000 ms
+ 179µs
コード長 1,481 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,028 ms
コンパイル使用メモリ 338,396 KB
実行使用メモリ 9,768 KB
最終ジャッジ日時 2026-09-05 12:44:52
合計ジャッジ時間 5,105 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll inf = (1LL<<60);

int main() {
    int T;
    cin >> T;

    while(T){
        T--;

        string str,ptn;
        int x;
        cin >> str >> ptn >> x;

        int len = str.length();

        if(ptn == "Warong"){
            bool check = true;
            queue<int> que;

            for(int i=0;i<len;i++){
                if(i < x) str[i] = 'A';
                else{
                    if(str[i] == '?') que.push(i);
                    if(str[i] == 'W') check = false;
                }
            }

            if(que.size() == 1 && check){
                str[que.front()] = 'W';
            }

            cout << str << endl;
        }

        if(ptn == "NotWarong"){
            bool frontAllA = true,backwExist = false, frontwExist = false;
            queue<int>que;

            for(int i=0;i<x;i++){
                if(str[i] != 'A'){
                    frontAllA = false;

                    if(str[i] == 'W') frontwExist = true;
                    if(str[i] == '?') que.push(i);
                }
            }

            for(int i=x;i<len;i++){
                if(str[i] == 'W') backwExist = true;
            }

            if(frontAllA){
                string ans(len,'A');
                str = ans;
            }else if(!frontwExist && backwExist && que.size() == 1){
                str[que.front()] = 'W';
            }

            cout << str << endl;
        }
    }
}
0