結果
| 問題 |
No.2978 Lexicographically Smallest and Largest Subarray
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2024-12-02 08:47:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 212 ms / 2,000 ms |
| コード長 | 1,081 bytes |
| コンパイル時間 | 3,325 ms |
| コンパイル使用メモリ | 251,328 KB |
| 実行使用メモリ | 25,464 KB |
| 平均クエリ数 | 1499.00 |
| 最終ジャッジ日時 | 2024-12-02 08:48:11 |
| 合計ジャッジ時間 | 17,032 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 57 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n,q;
cin>>n>>q;
queue<int> B,S;
for(int i=1;i<=n;i+=2){
cout<<"? "<<i<<" "<<n<<" "<<i+1<<" "<<n<<endl;
int x;
cin>>x;
if(x==-1) return 0;
if(x==1) B.push(i+1),S.push(i);
else B.push(i),S.push(i+1);
}
while(B.size()>1){
auto a=B.front(); B.pop();
auto b=B.front(); B.pop();
cout<<"? "<<a<<" "<<n<<" "<<b<<" "<<n<<endl;
int x;
cin>>x;
if(x==-1) return 0;
if(x==1) B.push(b);
else B.push(a);
}
while(S.size()>1){
auto a=S.front(); S.pop();
auto b=S.front(); S.pop();
cout<<"? "<<a<<" "<<a<<" "<<b<<" "<<b<<endl;
int x;
cin>>x;
if(x==-1) return 0;
if(x==1) S.push(a);
else S.push(b);
}
auto a=B.front(),b=S.front();
cout<<"! "<<b<<" "<<b<<" "<<a<<" "<<n<<endl;
return 0;
}
umezo