結果
| 問題 | No.2978 Lexicographically Smallest and Largest Subarray |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-02 19:47:41 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 2,000 ms |
| コード長 | 730 bytes |
| 記録 | |
| コンパイル時間 | 1,114 ms |
| コンパイル使用メモリ | 220,512 KB |
| 実行使用メモリ | 9,264 KB |
| 平均クエリ数 | 1499.00 |
| 最終ジャッジ日時 | 2026-07-06 06:09:09 |
| 合計ジャッジ時間 | 8,536 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 57 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
bool deb = 1;
int N,Q;
int ask(int l,int r){
cout<<"? "<<l<<" "<<N<<" "<<r<<" "<<N<<endl;
int X;
cin>>X;
return X;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>Q;
queue<int> B[2],S;
for(int i=1;i<N;i+=2){
int x=ask(i,i+1);
B[x].push(i+1);
B[1-x].push(i);
}
for(int i=0;i<2;i++){
while(B[i].size()>1){
int p=B[i].front();
B[i].pop();
int q=B[i].front();
B[i].pop();
B[i].push(ask(p,q)!=i?p:q);
}
}
cout<<"! "<<B[0].front()<<" "<<B[0].front()<<" "<<B[1].front()<<" "<<N<<"\n";
}