結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー phspls
提出日時 2022-09-19 04:36:36
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 14,546 ms
コンパイル使用メモリ 380,024 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-22 02:15:02
合計ジャッジ時間 14,740 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 17 WA * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
 --> src/main.rs:5:9
  |
5 |     let n: usize = n.trim().parse().unwrap();
  |         ^ help: if this is intentional, prefix it with an underscore: `_n`
  |
  = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s = s.trim().chars().collect::<Vec<char>>();

    let mut cnts = vec![vec![0usize; 3]; 3];
    for i in 0..s.len() {
        let c = s[i];
        if c == 'c' {
            cnts[0][i%3] += 1;
        } else if c == 'o' {
            cnts[1][i%3] += 1;
        } else if c == 'n' {
            cnts[2][i%3] += 1;
        }
    }
    println!("{}", (0..3).map(|i| cnts[0][i].min(cnts[1][(i+1)%3]).min(cnts[2][(i+2)%3])).sum::<usize>());
}
0