結果

問題 No.769 UNOシミュレータ
ユーザー ducktailducktail
提出日時 2018-12-18 17:39:31
言語 Rust
(1.77.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,617 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 145,916 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 11:56:01
合計ジャッジ時間 2,256 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 13 ms
4,376 KB
testcase_13 AC 13 ms
4,380 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 26 ms
4,380 KB
testcase_16 AC 26 ms
4,376 KB
testcase_17 AC 26 ms
4,380 KB
testcase_18 AC 39 ms
4,380 KB
testcase_19 AC 38 ms
4,380 KB
testcase_20 AC 39 ms
4,376 KB
testcase_21 AC 38 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main(){
  let nm: Vec<isize> = read_vec();
  let n = nm[0];
  let m = nm[1];
  let mut cnt : Vec<i32> = vec![0; n as usize];
  let mut t: isize = 0;
  let mut dir: isize = 1;
  let mut dr2: i32 = 0;
  let mut dr4: i32 = 0;

  let skip: String = "skip".to_string();
  let reverse: String = "reverse".to_string();
  let drawtwo: String = "drawtwo".to_string();
  let drawfour: String = "drawfour".to_string();
  
  for i in 0 .. m {
    let cd: String = read();

    if dr2 > 0 && cd != drawtwo {
      cnt[t as usize] -= dr2 * 2;
      t = (t + dir + n) % n;
      dr2 = 0;
    }
    
    if dr4 > 0 && cd != drawfour {
      cnt[t as usize] -= dr4 * 4;
      t = (t + dir + n) % n;
      dr4 = 0;
    }

    cnt[t as usize] += 1;

    if i == m - 1 {
      println!("{} {}", t+1, cnt[t as usize]);
    }
    
    if cd == skip {
      t = (t + 2 * dir + n) % n;
    } else if cd == reverse {
      dir = 0 - dir;
      t = (t + dir + n) % n;
    } else if cd == drawtwo {
      dr2 += 1;
      t = (t + dir + n) % n;
    } else if cd == drawfour {
      dr4 += 1;
      t = (t + dir + n) % n;
    } else {
      t = (t + dir + n) % n;
    }
  }
  
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}
0