結果
| 問題 |
No.1650 Moving Coins
|
| コンテスト | |
| ユーザー |
fukafukatani
|
| 提出日時 | 2021-08-20 21:59:33 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,509 bytes |
| コンパイル時間 | 14,988 ms |
| コンパイル使用メモリ | 377,280 KB |
| 実行使用メモリ | 23,212 KB |
| 最終ジャッジ日時 | 2024-10-14 03:37:56 |
| 合計ジャッジ時間 | 26,320 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 1 WA * 23 |
コンパイルメッセージ
warning: variable does not need to be mutable --> src/main.rs:20:9 | 20 | let mut a = read_vec::<i64>(); | ----^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
ソースコード
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;
#[allow(unused_macros)]
macro_rules! debug {
($($e:expr),*) => {
#[cfg(debug_assertions)]
$({
let (e, mut err) = (stringify!($e), std::io::stderr());
writeln!(err, "{} = {:?}", e, $e).unwrap()
})*
};
}
fn main() {
let n = read::<usize>();
let mut a = read_vec::<i64>();
let b = read_vec::<i64>();
let mut opes = vec![vec![0]];
for i in 1..n {
if (a[i] <= b[i]) != (a[i - 1] <= b[i - 1]) {
opes.push(vec![]);
}
let last = opes.len() - 1;
opes[last].push(i);
}
let mut answers = vec![];
for ref mut block in &mut opes {
if a[block[0]] <= b[block[0]] {
block.reverse();
}
for &i in block.iter() {
for _ in 0..(a[i] - b[i]).abs() {
if a[i] <= b[i] {
answers.push((i, 'R'));
} else {
answers.push((i, 'L'));
}
}
}
}
for (i, ch) in answers {
println!("{} {}", i + 1, ch);
}
}
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}
fukafukatani