結果
問題 | No.2978 Lexicographically Smallest and Largest Subarray |
ユーザー |
![]() |
提出日時 | 2024-12-12 10:30:46 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 201 ms / 2,000 ms |
コード長 | 954 bytes |
コンパイル時間 | 7,588 ms |
コンパイル使用メモリ | 278,160 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 1499.00 |
最終ジャッジ日時 | 2024-12-12 10:31:10 |
合計ジャッジ時間 | 17,890 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 57 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<VL> VVL; typedef long long LL; #define all(a) (a).begin(), (a).end() #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define ALL(a) (a).begin(),(a).end() #define pb push_back int main() { int n,q;cin>>n>>q; VI A,B; if(n%2){A.pb(n);} for(int i=1;i<n;i+=2){ cout<<"? "<<i<<' '<<n<<' '<<i+1<<' '<<n<<endl; bool h;cin>>h; if(h){A.pb(i+1);B.pb(i);} else{A.pb(i);B.pb(i+1);} }//Aが大 int a=A[0]; int m=A.size(); for(int i=1;i<m;i++){ cout<<"? "<<a<<' '<<n<<' '<<A[i]<<' '<<n<<endl; bool h;cin>>h; if(h){a=A[i];} } int b=B[0]; m=B.size(); for(int i=1;i<m;i++){ cout<<"? "<<b<<' '<<n<<' '<<B[i]<<' '<<n<<endl; bool h;cin>>h; if(!h){b=B[i];} } cout<<"! "<<b<<' '<<b<<' '<<a<<' '<<n<<endl; }