結果
問題 | No.769 UNOシミュレータ |
ユーザー | phspls |
提出日時 | 2020-02-19 22:53:51 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 1,977 bytes |
コンパイル時間 | 12,934 ms |
コンパイル使用メモリ | 386,108 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-02 00:45:19 |
合計ジャッジ時間 | 14,542 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 0 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 10 ms
5,376 KB |
testcase_13 | AC | 10 ms
5,376 KB |
testcase_14 | AC | 10 ms
5,376 KB |
testcase_15 | AC | 19 ms
5,376 KB |
testcase_16 | AC | 19 ms
5,376 KB |
testcase_17 | AC | 18 ms
5,376 KB |
testcase_18 | AC | 28 ms
5,376 KB |
testcase_19 | AC | 29 ms
5,376 KB |
testcase_20 | AC | 28 ms
5,376 KB |
testcase_21 | AC | 27 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 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]); }