結果
問題 |
No.26 シャッフルゲーム
|
ユーザー |
|
提出日時 | 2021-04-06 14:50:43 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 1,151 bytes |
コンパイル時間 | 16,004 ms |
コンパイル使用メモリ | 379,976 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-03 08:24:36 |
合計ジャッジ時間 | 16,832 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#[allow(dead_code)] mod cc { pub fn read_line() -> Option<String> { let mut buf = String::new(); let len = std::io::stdin().read_line(&mut buf).ok(); if let Some(0) = len { None } else { Some(buf.trim().to_string()) } } pub fn parse_to<T: std::str::FromStr>(s: String) -> T { s.trim().parse().ok().unwrap() } pub fn drop_line() { read_line(); } } fn read_data() -> (u8, Vec<[u8; 2]>) { let n: u8 = cc::parse_to(cc::read_line().unwrap()); cc::drop_line(); let mut vs: Vec<[u8; 2]> = Vec::new(); while let Some(_s) = cc::read_line() { let _v: Vec<u8> = _s .split_ascii_whitespace() .map(|e| e.parse().ok().unwrap()) .collect(); vs.push([_v[0], _v[1]]); } (n, vs) } fn calc(n: u8, v: Vec<[u8; 2]>) -> u8 { let mut now = n; for [left, right] in v { if now == left { now = right; } else if now == right { now = left; } } now } fn main() { let (n, v) = read_data(); println!("{}", calc(n, v)); }