結果

問題 No.2298 yukicounter
ユーザー Lisp_CoderLisp_Coder
提出日時 2023-05-13 19:28:35
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,070 bytes
コンパイル時間 13,733 ms
コンパイル使用メモリ 400,988 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 00:00:01
合計ジャッジ時間 14,497 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 = read_string();
    let mut ans = 0;
    let mut cnt = 0;
    for i in 0..s.len() {
        if s[i..].starts_with("yukicoder") {
            cnt += 1;
            ans = std::cmp::max(ans, cnt);
        } else {
            cnt = 0;
        }
    }
    outi(ans);
}
0