結果
| 問題 | No.3685 ワロングアンサーやんけ! |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-09-05 16:21:42 |
| 言語 | Rust (1.97.1 + proconio + num + itertools) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,896 bytes |
| 記録 | |
| コンパイル時間 | 1,131 ms |
| コンパイル使用メモリ | 195,272 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-09-05 16:21:49 |
| 合計ジャッジ時間 | 4,637 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 WA * 19 |
ソースコード
#![allow(non_snake_case, unused_imports)]
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashMap, HashSet};
use proconio::{input, marker::Usize1, marker::Chars};
use itertools::Itertools;
#[allow(unused_macros)]
macro_rules! d {
( $( $x:expr ),* $(,)? ) => {
eprintln!(
concat!( $( stringify!($x), "={:?} " ),* ),
$( $x ),*
);
};
}
#[allow(dead_code)]
fn yn(b: bool) -> &'static str {
if b { "Yes" } else { "No" }
}
fn solve() -> String {
input! {
R: String,
S: String,
K: usize,
}
if S == "NotWarong" {
if R.chars().take(K).all(|c| c == 'A') {
let mut s = String::new();
for c in R.chars() {
if c == '?' {
s.push('A')
} else {
s.push(c)
}
}
return s
}
let freq = R.chars().counts();
let qcnt = *freq.get(&'?').unwrap_or(&0);
let wcnt = *freq.get(&'W').unwrap_or(&0);
let hd_qcnt = R.chars()
.take(K)
.filter(|&c| c == '?')
.count();
if wcnt == 0 && hd_qcnt == 1 && qcnt == 1 {
let r = R.replace('?', "W");
return r
}
return R;
}
let freq = R.chars().skip(K as usize).counts();
let qcnt = *freq.get(&'?').unwrap_or(&0);
let wcnt = *freq.get(&'W').unwrap_or(&0);
let mut s = String::new();
for _ in 0..K {
s.push('A');
}
let cs: Vec<char> = R.chars().collect();
for i in K as usize..R.len() {
if cs[i] == '?' && qcnt == 1 && wcnt == 0 {
s.push('W');
} else {
s.push(cs[i]);
}
}
s
}
fn main() {
input! {
T: usize,
}
for _ in 0..T {
let ans = solve();
println!("{}", ans);
}
}
norioc