結果
| 問題 | No.3685 ワロングアンサーやんけ! |
| コンテスト | |
| ユーザー |
よには
|
| 提出日時 | 2026-09-19 18:04:41 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 178 ms / 2,000 ms |
| + 53µs | |
| コード長 | 1,574 bytes |
| 記録 | |
| コンパイル時間 | 6,288 ms |
| コンパイル使用メモリ | 410,952 KB |
| 実行使用メモリ | 10,000 KB |
| 最終ジャッジ日時 | 2026-09-19 18:05:10 |
| 合計ジャッジ時間 | 8,957 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 32 |
ソースコード
#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;
void solve(){
string r, s; int k; cin >> r >> s >> k;
int n = r.size();
if(s == "Warong"){
rep(i, k) r.at(i) = 'A';
int acnt = 0;
for(int i = k; i < n; i++) acnt += r.at(i) == 'A';
if(acnt == n - k - 1) for(int i = k; i < n; i++) if(r.at(i) != 'A') r.at(i) = 'W';
}
else{
// 最初K文字にWが含まれるか、すべてがA
bool all_a = true, first_w = false;
rep(i, n) all_a &= r.at(i) != 'W';
rep(i, k) first_w |= r.at(i) != 'A';
if(!all_a){
// 前半K文字にWが含まれなくてはならない
// 前半K文字の?が1つかつWがないなら?をWに
int qcnt = 0, wcnt = 0;
rep(i, k){
qcnt += r.at(i) == '?';
wcnt += r.at(i) == 'W';
}
if(qcnt == 1 && wcnt == 0) rep(i, k) if(r.at(i) == '?') r.at(i) = 'W';
}
if(!first_w){
for(auto&& c : r) c = 'A';
}
}
println("{}", r);
}
signed main(){
int t; cin >> t;
while(t--) solve();
}
よには