結果
問題 | No.769 UNOシミュレータ |
ユーザー | phspls |
提出日時 | 2020-02-19 22:53:51 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 1,977 bytes |
コンパイル時間 | 15,210 ms |
コンパイル使用メモリ | 384,904 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-22 09:32:57 |
合計ジャッジ時間 | 14,693 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,820 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,816 KB |
testcase_04 | AC | 1 ms
6,816 KB |
testcase_05 | AC | 1 ms
6,816 KB |
testcase_06 | AC | 1 ms
6,820 KB |
testcase_07 | AC | 1 ms
6,820 KB |
testcase_08 | AC | 1 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 2 ms
6,820 KB |
testcase_11 | AC | 2 ms
6,816 KB |
testcase_12 | AC | 11 ms
6,820 KB |
testcase_13 | AC | 11 ms
6,820 KB |
testcase_14 | AC | 11 ms
6,816 KB |
testcase_15 | AC | 21 ms
6,820 KB |
testcase_16 | AC | 20 ms
6,816 KB |
testcase_17 | AC | 20 ms
6,816 KB |
testcase_18 | AC | 30 ms
6,820 KB |
testcase_19 | AC | 31 ms
6,816 KB |
testcase_20 | AC | 30 ms
6,816 KB |
testcase_21 | AC | 30 ms
6,820 KB |
testcase_22 | AC | 1 ms
6,820 KB |
ソースコード
fn next(n: usize, player: usize, reverse: bool) -> usize { if reverse { (n + player - 1) % n } else { (player + 1) % n } } fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n: usize = nm[0]; let m: usize = nm[1]; let mut cards: Vec<isize> = vec![0; n]; let mut reverse: bool = false; let mut player: usize = 0; let mut bombing2: bool = false; let mut bombing4: bool = false; let mut bombing_count: isize = 0; for i in 0..m { let mut card = String::new(); std::io::stdin().read_line(&mut card).ok(); let card: &str = card.trim(); if bombing2 { match card { "drawtwo" => {}, _ => { bombing2 = false; cards[player] += bombing_count; bombing_count = 0; player = next(n, player, reverse); }, } } if bombing4 { match card { "drawfour" => {}, _ => { bombing4 = false; cards[player] += bombing_count; bombing_count = 0; player = next(n, player, reverse); }, } } if i == m-1 { cards[player] += 1; break; } else { cards[player] += 1; match card { "drawtwo" => { bombing2 = true; bombing_count -= 2; }, "drawfour" => { bombing4 = true; bombing_count -= 4; }, "skip" => { player = next(n, player, reverse); }, "reverse" => { reverse = !reverse; }, _ => {}, } player = next(n, player, reverse); } } println!("{} {}", player+1, cards[player]); }