結果
| 問題 | No.3685 ワロングアンサーやんけ! |
| コンテスト | |
| ユーザー |
Uzawa_Reisa
|
| 提出日時 | 2026-09-05 13:31:37 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,374 bytes |
| 記録 | |
| コンパイル時間 | 5,126 ms |
| コンパイル使用メモリ | 307,972 KB |
| 実行使用メモリ | 9,780 KB |
| 最終ジャッジ日時 | 2026-09-05 13:32:03 |
| 合計ジャッジ時間 | 6,475 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 WA * 13 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:76:56: warning: 'pos' may be used uninitialized [-Wmaybe-uninitialized]
76 | if (W_cnt == 0 && q_cnt == 1) R[pos] = 'W';
| ^
main.cpp:50:49: note: 'pos' was declared here
50 | int A_cnt = 0, W_cnt = 0, q_cnt = 0,pos;
| ^~~
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <climits>
#include <chrono>
#include <atcoder/all>
using namespace std;
/*
Warong:WがK+1文字目以降にあってK文字目までは全部A
Not:Warongを満たさない(K+1文字目以降にWがないか最初のK文字にWが混ざっている)
WarongならRのK文字目までで?があったらAにする、K+1文字目以降でWがなく、?が一つだけなら?をWにする
NotならK文字目まで全部Aを満たしていたらK+1文字目以降の?はすべてA、
K+1文字目以降にWが混ざっていたらK文字目までで?が一つでWがなければ?をWにする
*/
int main(){
long long T;
cin >> T;
for (int i = 0; i < T; i++){
string R,S;
int K;
cin >> R >> S >> K;
if (S[0] == 'W'){
for (int j = 0; j < K; j++){
if (R[j] == '?') R[j] = 'A';
}
int q_cnt = 0,W_cnt = 0,pos = 0;;
for (int j = K; j <= int(R.size()); j++){
if (R[j] == 'W'){
W_cnt++;
}
}
if (q_cnt == 1 && W_cnt == 0) R[pos] = 'W';
cout << R << "\n";
}
else {
int A_cnt = 0, W_cnt = 0, q_cnt = 0,pos;
for (int j = 0; j < K; j++){
if (R[j] == 'A') A_cnt++;
}
for (int j = K; j < int(R.size()); j++){
if (R[j] == 'W'){
W_cnt++;
}
}
if (A_cnt == K){
for (int j = K; j < int(R.size()); j++){
if (R[j] == '?') R[j] = 'A';
}
}
else {
if (W_cnt > 0){
W_cnt = 0;
for (int j = 0; j < K; j++){
if (R[j] == 'W') W_cnt++;
if (R[j] == '?'){
q_cnt++;
if (q_cnt == 1) pos = j;
}
}
if (W_cnt == 0 && q_cnt == 1) R[pos] = 'W';
}
}
cout << R << "\n";
}
}
return 0;
}
Uzawa_Reisa