結果
問題 |
No.2978 Lexicographically Smallest and Largest Subarray
|
ユーザー |
👑 |
提出日時 | 2024-12-01 22:32:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 204 ms / 2,000 ms |
コード長 | 821 bytes |
コンパイル時間 | 3,202 ms |
コンパイル使用メモリ | 248,400 KB |
実行使用メモリ | 25,592 KB |
平均クエリ数 | 1499.00 |
最終ジャッジ日時 | 2024-12-01 23:35:40 |
合計ジャッジ時間 | 15,975 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 57 |
ソースコード
#include <bits/stdc++.h> using namespace std; int N, Q; int query(int l, int r, int L, int R) { cout << "? " << l << " " << r << " " << L << " " << R << endl; int X; cin >> X; return X; } void answer(int l, int r, int L, int R) { cout << "! " << l << " " << r << " " << L << " " << R << endl; } class Index { public: int l; Index(int l) : l(l) {} bool operator < (const Index& other) { int X = query(this->l, N, other.l, N); return X == 1; } bool operator >= (const Index& other) { int X = query(this->l, N, other.l, N); return X == 0; } }; int main() { cin >> N >> Q; vector<Index> indexes; for (int i = 1; i <= N; i++) { indexes.push_back(Index(i)); } auto [min_idx, max_idx] = minmax_element(indexes.begin(), indexes.end()); answer(min_idx->l, min_idx->l, max_idx->l, N); }