結果
| 問題 |
No.2978 Lexicographically Smallest and Largest Subarray
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2024-12-01 22:47:32 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 209 ms / 2,000 ms |
| コード長 | 807 bytes |
| コンパイル時間 | 2,900 ms |
| コンパイル使用メモリ | 248,376 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 1499.00 |
| 最終ジャッジ日時 | 2024-12-01 23:35:42 |
| 合計ジャッジ時間 | 17,060 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
struct Index {
int l;
Index(int _l) {
l = _l;
}
bool operator < (const Index& other) {
int X = query(l, N, other.l, N);
return X == 1;
}
bool operator >= (const Index& other) {
int X = query(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);
}