結果

問題 No.594 壊れた宝物発見機
ユーザー aimyaimy
提出日時 2017-11-12 11:15:18
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 4,881 bytes
コンパイル時間 11,765 ms
コンパイル使用メモリ 396,088 KB
実行使用メモリ 25,628 KB
平均クエリ数 100.65
最終ジャッジ日時 2024-07-16 14:45:57
合計ジャッジ時間 15,615 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 AC 101 ms
24,580 KB
testcase_17 AC 100 ms
25,220 KB
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:98:9
   |
98 |     buf.trim_right().parse::<T>().ok().unwrap()
   |         ^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated method
   |
98 |     buf.trim_end().parse::<T>().ok().unwrap()
   |         ~~~~~~~~

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
   --> src/main.rs:113:22
    |
113 |     let mut it = buf.trim_right().split_whitespace();
    |                      ^^^^^^^^^^
    |
help: replace the use of the deprecated method
    |
113 |     let mut it = buf.trim_end().split_whitespace();
    |                      ~~~~~~~~

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
   --> src/main.rs:131:22
    |
131 |     let mut it = buf.trim_right().split_whitespace();
    |                      ^^^^^^^^^^
    |
help: replace the use of the deprecated method
    |
131 |     let mut it = buf.trim_end().split_whitespace();
    |                      ~~~~~~~~

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

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
   --> src/main.rs:165:9
    |
165 |     buf.trim_right().chars().collect()
    |         ^^^^^^^^^^
    |
help: replace the use of the deprecated method
    |
165 |     buf.trim_end().chars().collect()
    |         ~~~~~~~~

ソースコード

diff #

fn main() {
  let (mut xl, mut yl, mut zl) = (-100, -100, -100);
  let (mut xr, mut yr, mut zr) = (100, 100, 100);

  let dl = {println!("? {} {} {}", xl, 0, 0); get::val::<usize>()};
  let dr = {println!("? {} {} {}", xr, 0, 0); get::val::<usize>()};

  loop {
    let x1 = xl + (xr - xl) / 3;
    let x2 = xr - (xr - xl) / 3;
    let d1 = {println!("? {} {} {}", x1, 0, 0); get::val::<usize>()};
    let d2 = {println!("? {} {} {}", x2, 0, 0); get::val::<usize>()};
    match 0 {
      _ if dl<d1 && d1<d2 && d2<dr => {xr = x1},
      _ if dl>d1 && d1<d2 => {xr = x2},
      _ if d1>d2 && d2<dr => {xl = x1},
      _ => {xl = x2}
    }
    if xr - xl == 2 {break}
  }

  let d1 = {println!("? {} {} {}", xl, 0, 0); get::val::<usize>()};
  let d2 = {println!("? {} {} {}", (xl+xr)/2, 0, 0); get::val::<usize>()};
  let d3 = {println!("? {} {} {}", xr, 0, 0); get::val::<usize>()};

  let x = match 0 {
    _ if d1<d2 && d1<d3 => {xl},
    _ if d3<d2 && d3<d1 => {xr},
    _ => {(xl+xr)/2}
  };

  let dl = {println!("? {} {} {}", 0, yl, 0); get::val::<usize>()};
  let dr = {println!("? {} {} {}", 0, yr, 0); get::val::<usize>()};

  loop {
    let y1 = yl + (yr - yl) / 3;
    let y2 = yr - (yr - yl) / 3;
    let d1 = {println!("? {} {} {}", 0, y1, 0); get::val::<usize>()};
    let d2 = {println!("? {} {} {}", 0, y2, 0); get::val::<usize>()};
    match 0 {
      _ if dl<d1 && d1<d2 && d2<dr => {yr = y1},
      _ if dl>d1 && d1<d2 => {yr = y2},
      _ if d1>d2 && d2<dr => {yl = y1},
      _ => {yl = y2}
    }
    if yr - yl == 2 {break}
  }

  let d1 = {println!("? {} {} {}", 0, yl, 0); get::val::<usize>()};
  let d2 = {println!("? {} {} {}", 0, (yl+yr)/2, 0); get::val::<usize>()};
  let d3 = {println!("? {} {} {}", 0, yr, 0); get::val::<usize>()};

  let y = match 0 {
    _ if d1<d2 && d1<d3 => {yl},
    _ if d3<d2 && d3<d1 => {yr},
    _ => {(yl+yr)/2}
  };

  let dl = {println!("? {} {} {}", 0, 0, zl); get::val::<usize>()};
  let dr = {println!("? {} {} {}", 0, 0, zr); get::val::<usize>()};

  loop {
    let z1 = zl + (zr - zl) / 3;
    let z2 = zr - (zr - zl) / 3;
    let d1 = {println!("? {} {} {}", 0, 0, z1); get::val::<usize>()};
    let d2 = {println!("? {} {} {}", 0, 0, z2); get::val::<usize>()};
    match 0 {
      _ if dl<d1 && d1<d2 && d2<dr => {zr = z1},
      _ if dl>d1 && d1<d2 => {zr = z2},
      _ if d1>d2 && d2<dr => {zl = z1},
      _ => {zl = z2}
    }
    if zr - zl == 2 {break}
  }

  let d1 = {println!("? {} {} {}", 0, 0, zl); get::val::<usize>()};
  let d2 = {println!("? {} {} {}", 0, 0, (zl+zr)/2); get::val::<usize>()};
  let d3 = {println!("? {} {} {}", 0, 0, zr); get::val::<usize>()};

  let z = match 0 {
    _ if d1<d2 && d1<d3 => {zl},
    _ if d3<d2 && d3<d1 => {zr},
    _ => {(zl+zr)/2}
  };

  println!("! {} {} {}", x, y, z);
}

#[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