結果

問題 No.3018 目隠し宝探し
ユーザー
提出日時 2025-01-29 11:42:42
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 13,350 ms
コンパイル使用メモリ 397,168 KB
実行使用メモリ 26,368 KB
平均クエリ数 2.73
最終ジャッジ日時 2025-01-29 11:43:02
合計ジャッジ時間 16,484 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: value assigned to `d` is never read
  --> src/main.rs:11:25
   |
11 |     let (mut x, mut y, mut d) = (1, 1, 0);
   |                            ^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

ソースコード

diff #

fn c() -> String {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	s.trim().to_string()
}
fn o() -> i64 {
	println!("? 1 1");
	c().parse().unwrap()
}
fn main() {
	let (mut x, mut y, mut d) = (1, 1, 0);
	let f: Vec<i64> = c().split_whitespace().flat_map(str::parse).collect();
	match f.as_slice() {
		[1, 1] => println!("! 1 1"),
		[1, _] => {
			d = o();
			y = (1..=f[1]).find(|&y| (y - 1).pow(2) == d).unwrap();
		}
		[_, 1] => {
			d = o();
			x = (1..=f[0]).find(|&x| (x - 1).pow(2) == d).unwrap();
		}
		_ => {
			let u = o();
			println!("? 1 {}", f[1]);
			let v = c().parse::<i64>().unwrap();
			d = (u - v - 1 + f[1].pow(2)) / 2;
			y = (d / (f[1] - 1)).abs();
			x = (1..=f[0])
				.find(|&x| (y - 1).pow(2) + (x - 1).pow(2) == u)
				.unwrap();
		}
	}
	println!("! {x} {y}");
}
0