結果

問題 No.3685 ワロングアンサーやんけ!
コンテスト
ユーザー dokukuma
提出日時 2026-09-05 14:36:36
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,995 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 246 ms
コンパイル使用メモリ 96,280 KB
実行使用メモリ 93,184 KB
最終ジャッジ日時 2026-09-05 14:36:49
合計ジャッジ時間 7,893 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys, time, random, heapq, math, itertools, copy
from collections import deque, Counter, defaultdict
#from sortedcontainers import SortedSet, SortedList
from bisect import bisect, bisect_left, bisect_right
import heapq as hq
from functools import cache, cmp_to_key
def debug(*x):print('debug:',*x, file=sys.stderr)
sys.setrecursionlimit(300000)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353
dir = [(0, 1), (0, -1), (1, 0), (-1, 0)]

T = ii()
for _ in range(T):
    R = list(input())
    S = input()
    K = ii()
    if S == "Warong":
        # 最初K文字はAで確定する
        for i in range(K):
            R[i] = "A"
        # 残りについて,Wがないかつ?が一つならそこはW確定
        cnt_W = False
        cnt_hatena = 0
        for i in range(len(R)):
            if R[i] == "?":
                cnt_hatena += 1
            if R[i] == "W":
                cnt_W += 1
        if cnt_W == 0 and cnt_hatena == 1:
            for i in range(len(R)):
                if R[i] == "?":
                    R[i] = "W"
                    break
    else:
        
        cnt_A = 0
        cnt_hatena = 0
        cnt_W_all = 0
        for i in range(K):
            if R[i] == "?":
                cnt_hatena += 1
            if R[i] == "A":
                cnt_A += 1

        for i in range(len(R)):
            if R[i] == "W":
                cnt_W_all += 1

        #最初のK文字がすべてAなら全体はA
        if cnt_A == K:
            for i in range(K):
                R[i] = "A"
        # Wが一つ以上含まれているなら最初のK文字のうち一つ以上Wである
        elif cnt_W_all >= 1:
            if cnt_hatena == 1 and cnt_A == K-1:
                for i in range(K):
                    if R[i] == "?":
                        R[i] = "W"
                        break
        


    print("".join(R))

0