結果
| 問題 |
No.2041 E-mail Address
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-07 19:49:04 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#[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(())
}