結果

問題 No.610 区間賞(Section Award)
ユーザー aimyaimy
提出日時 2017-12-10 09:27:49
言語 Rust
(1.77.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 3,109 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 167,876 KB
実行使用メモリ 10,512 KB
最終ジャッジ日時 2023-08-20 09:50:09
合計ジャッジ時間 5,480 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 18 ms
4,744 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 12 ms
4,440 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 9 ms
4,376 KB
testcase_27 AC 18 ms
4,720 KB
testcase_28 AC 16 ms
4,864 KB
testcase_29 AC 11 ms
4,428 KB
testcase_30 AC 15 ms
5,120 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 17 ms
4,936 KB
testcase_33 AC 4 ms
4,376 KB
testcase_34 AC 18 ms
4,384 KB
testcase_35 AC 9 ms
4,376 KB
testcase_36 AC 17 ms
4,984 KB
testcase_37 AC 15 ms
4,664 KB
testcase_38 AC 5 ms
4,376 KB
testcase_39 AC 20 ms
5,240 KB
testcase_40 AC 19 ms
5,192 KB
testcase_41 AC 20 ms
5,216 KB
testcase_42 AC 19 ms
5,108 KB
testcase_43 AC 19 ms
5,172 KB
testcase_44 AC 31 ms
9,120 KB
testcase_45 AC 38 ms
10,484 KB
testcase_46 AC 39 ms
10,512 KB
testcase_47 AC 15 ms
5,404 KB
testcase_48 AC 14 ms
4,572 KB
testcase_49 AC 16 ms
5,432 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> Main.rs:56:9
   |
56 |     buf.trim_right().parse::<T>().ok().unwrap()
   |         ^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated associated function
   |
56 |     buf.trim_end().parse::<T>().ok().unwrap()
   |         ~~~~~~~~

warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> Main.rs:71:22
   |
71 |     let mut it = buf.trim_right().split_whitespace();
   |                      ^^^^^^^^^^
   |
help: replace the use of the deprecated associated function
   |
71 |     let mut it = buf.trim_end().split_whitespace();
   |                      ~~~~~~~~

warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> Main.rs:89:22
   |
89 |     let mut it = buf.trim_right().split_whitespace();
   |                      ^^^^^^^^^^
   |
help: replace the use of the deprecated associated function
   |
89 |     let mut it = buf.trim_end().split_whitespace();
   |                      ~~~~~~~~

warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end`
   --> Main.rs:108:9
    |
108 |     buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
    |         ^^^^^^^^^^
    |
help: replace the use of the deprecated associated function
    |
108 |     buf.trim_end().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
    |         ~~~~~~~~

warning: use of deprecated associated function `core::str::<impl str>::trim_right`: superseded by `trim_end`
   --> Main.rs:123:9
    |
123 |     buf.trim_right().chars().collect()
    |         ^^^^^^^^^^
    |
help: replace the use of the deprecated associated function
    |
123 |     buf.trim_end().chars().collect()
    |         ~~~~~~~~

warning: 5 warnings emitt

ソースコード

diff #

#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

use std::collections::HashSet;
use std::collections::VecDeque;

fn main() {
  let _ = get::val::<usize>();
  let mut xs = get::list::<usize>().into_iter().collect::<VecDeque<_>>();
  let bs = get::list::<usize>();

  let mut xset = xs.iter().cloned().collect::<HashSet<_>>();
  let mut ans = vec![];

  for b in bs {
    if xset.remove(&b) {
      ans.push(b);
      while !xs.is_empty() && *xs.front().unwrap() != b {
        let x = xs.pop_front().unwrap();
        let _ = xset.remove(&x);
      }
    }
  }

  ans.sort();
  put::vec(&ans, "\n")
}

#[allow(dead_code)]
mod put {
  use std::string::*;

  pub fn vec<T: ToString>(vec: &Vec<T>, sep: &str) {
    let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join(sep);
    println!("{}", out);
  }

  pub fn mat<T: ToString>(mat: &Vec<Vec<T>>, sep: &str) {
    for v in mat {
      vec(v, sep);
    }
  }
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}
0