結果

問題 No.2049 POP
ユーザー yuzu32utyuzu32ut
提出日時 2022-10-07 19:08:33
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,590 bytes
コンパイル時間 984 ms
コンパイル使用メモリ 141,356 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 20:01:13
合計ジャッジ時間 1,815 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 1 ms
4,368 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 1 ms
4,372 KB
testcase_10 AC 1 ms
4,368 KB
testcase_11 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(dead_code)]
pub mod nayuta {
    use std::{error::Error, str::FromStr};
    use std::{io, result};
    pub type Result<T> = result::Result<T, Box<dyn Error>>;

    fn input_values<T>() -> Result<Vec<T>>
    where
        T: FromStr,
        <T as FromStr>::Err: 'static + Error,
    {
        let s: String = input_string()?;
        let v: Vec<T> = s
            .split_ascii_whitespace()
            .map(|x: &str| -> Result<T> { x.parse::<T>().map_err(|e| e.into()) })
            .collect::<Result<_>>()?;
        Ok(v)
    }

    /// データを1行分、単一の文字列として読み込む
    ///
    /// 末尾の改行は取り除かれます。たぶん空白も
    pub fn input_string() -> Result<String> {
        let mut s: String = String::new();
        io::stdin().read_line(&mut s)?;
        Ok(s.trim().into())
    }

    /// データを1行分、1つのデータとして読み込む
    pub fn input_single<T>() -> Result<T>
    where
        T: FromStr,
        <T as FromStr>::Err: 'static + Error,
    {
        let s: String = input_string()?;
        Ok(s.parse::<T>()?)
    }

    /// データを1行分、空白区切りの2要素として読み込む
    pub fn input_two_tuple<T>() -> Result<(T, T)>
    where
        T: FromStr + Copy,
        <T as FromStr>::Err: 'static + Error,
    {
        let v: Vec<T> = input_values()?;
        Ok((v[0], v[1]))
    }
}

fn main() -> nayuta::Result<()> {
    let n: usize = nayuta::input_single()?;
    let s: String = nayuta::input_string()?;
    println!("{}", s[1..n - 1].to_owned());

    Ok(())
}
0