結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 14:57:29 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,157 bytes |
| コンパイル時間 | 13,835 ms |
| コンパイル使用メモリ | 378,880 KB |
| 実行使用メモリ | 26,108 KB |
| 平均クエリ数 | 2.68 |
| 最終ジャッジ日時 | 2025-01-25 23:37:12 |
| 合計ジャッジ時間 | 17,435 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 RE * 13 |
ソースコード
use proconio::{input, source::line::LineSource};
use std::{
collections::BTreeSet,
io::{stdin, stdout, BufReader, Write},
};
fn main() {
let stdin = stdin();
let mut source = LineSource::new(BufReader::new(stdin.lock()));
input! {
from &mut source,
h: usize,
w: usize,
}
println!("? {} {}", 1, 1);
stdout().flush().unwrap();
input! {
from &mut source,
d: usize,
}
let rows = (0..h).map(|i| i * i).collect::<BTreeSet<_>>();
let cols = (0..w).map(|i| i * i).collect::<BTreeSet<_>>();
for &row in &rows {
if row > d {
break;
}
let col = *cols.range(..=d - row).next_back().unwrap();
if row + col != d {
continue;
}
let row_i = (row as f64).sqrt() as usize;
let col_i = (col as f64).sqrt() as usize;
println!("? {} {}", row_i + 1, col_i + 1);
stdout().flush().unwrap();
input! {
from &mut source,
d: usize,
}
if d == 0 {
println!("! {} {}", row_i + 1, col_i + 1);
return;
}
}
}