結果

問題 No.2041 E-mail Address
ユーザー yuzu32utyuzu32ut
提出日時 2022-10-07 19:49:04
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,703 bytes
コンパイル時間 11,092 ms
コンパイル使用メモリ 392,100 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 03:22:31
合計ジャッジ時間 11,989 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 0 ms
6,940 KB
testcase_05 AC 0 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 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 t: String = nayuta::input_string()?;
    let start: usize = t.chars().position(|c| c == '(').unwrap();
    let end: usize = t.chars().position(|c| c == ')').unwrap();
    println!("{}@{}", t[..start].to_owned(), t[end + 1..].to_owned());

    Ok(())
}
0