結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 19:18:58 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 2,000 ms |
| コード長 | 1,186 bytes |
| コンパイル時間 | 11,098 ms |
| コンパイル使用メモリ | 378,240 KB |
| 実行使用メモリ | 25,856 KB |
| 平均クエリ数 | 2.68 |
| 最終ジャッジ日時 | 2025-01-26 00:03:44 |
| 合計ジャッジ時間 | 14,125 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 21 |
ソースコード
use proconio::{input, source::line::LineSource};
use std::io::{stdin, stdout, BufReader, Write};
/// https://yukicoder.me/problems/no/3018
/// https://yukicoder.me/problems/no/3018/editorial
fn main() {
let stdin = stdin();
let mut source = LineSource::new(BufReader::new(stdin.lock()));
input! {
from &mut source,
h: i32,
w: i32,
}
if h == 1 && w == 1 {
println!("! 1 1");
return;
}
println!("? {} {}", 1, 1);
stdout().flush().unwrap();
input! {
from &mut source,
d: i32,
}
let d_root = (d as f64).sqrt() as i32;
if h == 1 {
println!("! 1 {}", d_root + 1);
return;
}
if w == 1 {
println!("! {} 1", d_root + 1);
return;
}
println!("? {} {}", 1, w);
stdout().flush().unwrap();
input! {
from &mut source,
d_h: i32,
}
for i in 1..=h {
for j in 1..=w {
if (i - 1) * (i - 1) + (j - 1) * (j - 1) == d
&& (i - 1) * (i - 1) + (j - w) * (j - w) == d_h
{
println!("! {} {}", i, j);
return;
}
}
}
}