結果
問題 |
No.2978 Lexicographically Smallest and Largest Subarray
|
ユーザー |
![]() |
提出日時 | 2024-12-14 10:53:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,056 bytes |
コンパイル時間 | 1,855 ms |
コンパイル使用メモリ | 175,244 KB |
実行使用メモリ | 110,016 KB |
最終ジャッジ日時 | 2024-12-14 10:56:29 |
合計ジャッジ時間 | 179,804 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 57 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N,Q;cin>>N>>Q; queue<int> mq,Mq; for(int i=1;i<=N;i+=2){ cout<<"? "<<i<<" "<<N<<" "<<i+1<<" "<<N<<endl; int f; cin>>f; if(f==-1)return 0; if(f){ Mq.push(i+1); mq.push(i); } else{ Mq.push(i); mq.push(i+1); } } while(Mq.size()>1){ queue<int> tmq,tMq; while(Mq.size()>2){ auto a=Mq.front(); Mq.pop(); auto b=Mq.front(); Mq.pop(); cout<<"? "<<a<<" "<<N<<" "<<b<<" "<<N<<endl; int f; if(f==-1)return 0; cin>>f; if(f){ tMq.push(b); } else{ tMq.push(a); } } while(tMq.size()){ Mq.push(tMq.front()); tMq.pop(); } while(mq.size()>2){ auto a=mq.front(); mq.pop(); auto b=mq.front(); mq.pop(); cout<<"? "<<a<<" "<<a<<" "<<b<<" "<<b<<endl; int f; cin>>f; if(f==-1)return 0; if(f){ tmq.push(a); } else{ tmq.push(b); } } while(tmq.size()){ mq.push(tmq.front()); tmq.pop(); } } cout<<"! "<<mq.front()<<" "<<mq.front()<<" "<<Mq.front()<<" "<<N<<endl; }