結果
問題 | No.2978 Lexicographically Smallest and Largest Subarray |
ユーザー |
![]() |
提出日時 | 2024-12-02 19:06:39 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 200 ms / 2,000 ms |
コード長 | 953 bytes |
コンパイル時間 | 12,068 ms |
コンパイル使用メモリ | 400,536 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 1501.00 |
最終ジャッジ日時 | 2024-12-02 19:07:07 |
合計ジャッジ時間 | 25,856 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 57 |
ソースコード
use proconio::input_interactive; fn main() { input_interactive! { n: usize, _q: usize, }; // a[1..], a[2..], ..., a[n..] let (mut min, mut max) = (1, 1); for i in (1..=n).step_by(2) { let (p, q) = (i, i + 1); if query((p, n), (q, n)) { // a[p..] < a[q..] if query((p, n), (min, n)) { min = p; } if query((max, n), (q, n)) { max = q; } } else { // a[p..] > a[q..] if query((q, n), (min ,n)) { min = q; } if query((max, n), (p, n)) { max = p; } } } println!("! {min} {min} {max} {n}"); } fn query((l1, r1): (usize, usize), (l2, r2): (usize, usize)) -> bool { println!("? {l1} {r1} {l2} {r2}"); input_interactive! { less: i8, } assert_ne!(less, -1); less == 1 }