結果

問題 No.3685 ワロングアンサーやんけ!
コンテスト
ユーザー よには
提出日時 2026-07-11 13:37:44
言語 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
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,974 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,371 ms
コンパイル使用メモリ 410,300 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-19 17:48:55
合計ジャッジ時間 9,486 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#if __has_include(<yoniha/all.h>)
#include <yoniha/all.h>
using namespace atcoder;
#else
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#endif
using namespace std;

#define int long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)((n) - 1); i >= 0; i--)
template <typename T> bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template <typename T> bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

// using mint = modint;

signed main(){
  int n, m; string s, t; cin >> n >> m >> s >> t;
  if(t == "Warong"){
    rep(i, m) s.at(i) = 'A';
    // ?が1文字で、他がすべてAならその?はWになる
    int q_cnt = 0, w_cnt = 0;
    for(auto c : s){
      q_cnt += c == '?';
      w_cnt += c == 'W';
    }
    if(q_cnt == 1 && w_cnt == 0){
      for(auto&& c : s) if(c == '?') c = 'W';
    }
  }
  if(t == "NotWarong"){
    // 最初のM文字に1文字以上Wが含まれる || すべてAである
    int w_cnt = 0;
    for(auto c : s) w_cnt += c == 'W';
    if(w_cnt == 0){
      // すべてAの可能性がある
      // 後半にWが入り、かつ前半M文字がすべてAだとアウト
      int a_front_cnt = 0;
      rep(i, m) a_front_cnt += s.at(i) == 'A';
      if(a_front_cnt == m){
        for(int i = m; i < n; i++) s.at(i) = 'A';
      }
    }
    else{
      // すでにWがあるので、後半の条件は達成されない
      // 前半のM文字に1文字以上Wが含まれる必要がある
      // 前半にWがなく前半の?が1文字ならそれをWにする
      int q_front_cnt = 0, w_front_cnt = 0;
      rep(i, m){
        q_front_cnt += s.at(i) == '?';
        w_front_cnt += s.at(i) == 'W';
      }
      if(q_front_cnt == 1 && w_front_cnt == 0){
        rep(i, m) if(s.at(i) == '?') s.at(i) = 'W';
      }
    }
  }
  println("{}", s);
}
0