結果
| 問題 | No.2978 Lexicographically Smallest and Largest Subarray |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-02 19:47:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 199 ms / 2,000 ms |
| コード長 | 730 bytes |
| 記録 | |
| コンパイル時間 | 2,158 ms |
| コンパイル使用メモリ | 199,792 KB |
| 最終ジャッジ日時 | 2025-02-26 10:39:43 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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";
}