結果

問題 No.2298 yukicounter
ユーザー Lisp_CoderLisp_Coder
提出日時 2023-05-13 19:26:13
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,114 bytes
コンパイル時間 13,884 ms
コンパイル使用メモリ 402,028 KB
実行使用メモリ 13,884 KB
最終ジャッジ日時 2024-05-06 23:57:51
合計ジャッジ時間 17,905 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
6,812 KB
testcase_02 WA -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 英小文字からなる文字列 S が与えられます.S に文字列 yukicoder が最大で何回連続して現れるかを求めてください.
// ただし,S に文字列 yukicoder が連続して現れない場合は 0 としてください.

use std::io::*;

#[allow(dead_code)]
// 文字列を読み込む関数
fn read_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().to_string()
}
#[allow(dead_code)]
// 整数を読み込む関数
fn read<T: std::str::FromStr>() -> T {
    let s = read_string();
    s.parse().ok().unwrap()
}
#[allow(dead_code)]
// スペース区切りの整数を読み込む関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let s = read_string();
    s.split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
// 文字列を出力する関数
fn out(s: &str) {
    println!("{}", s);
}
#[allow(dead_code)]
// 整数を出力する関数
fn outi<T: std::fmt::Display>(n: T) {
    println!("{}", n);
}
#[allow(dead_code)]
// スペース区切りの整数を出力する関数
fn out_vec<T: std::fmt::Display>(v: Vec<T>) {
    let mut s = String::new();
    for i in 0..v.len() {
        s += &v[i].to_string();
        if i != v.len() - 1 {
            s += " ";
        }
    }
    println!("{}", s);
}
#[allow(dead_code)]
// 改行区切りの整数を出力する関数
fn out_vec2<T: std::fmt::Display>(v: Vec<T>) {
    for i in 0..v.len() {
        println!("{}", v[i]);
    }
}
#[allow(dead_code)]
// 2次元配列を出力する関数
fn out_vec3<T: std::fmt::Display>(v: Vec<Vec<T>>) {
    for i in 0..v.len() {
        for j in 0..v[i].len() {
            print!("{} ", v[i][j]);
        }
        println!("");
    }
}

fn main() {
    let s: String = read();
    let mut ans = 0;
    let mut count = 0;
    for i in 0..s.len() {
        if s.chars().nth(i).unwrap() == 'y' {
            count += 1;
        } else {
            count = 0;
        }
        if count == 9 {
            ans += 1;
            count = 0;
        }
    }
    outi(ans);
}
0