結果
| 問題 | No.2978 Lexicographically Smallest and Largest Subarray |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-25 05:48:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 212 ms / 2,000 ms |
| コード長 | 460 bytes |
| コンパイル時間 | 827 ms |
| コンパイル使用メモリ | 64,000 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 1499.00 |
| 最終ジャッジ日時 | 2024-12-25 05:48:33 |
| 合計ジャッジ時間 | 13,660 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 57 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int N,Q;
bool ask(int a,int b)
{
cout<<"? "<<a<<" "<<N<<" "<<b<<" "<<N<<endl;
int x;cin>>x;
return x==1;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>Q;
int mn,mx;
if(ask(1,2))mn=1,mx=2;
else mn=2,mx=1;
for(int i=3;i<N;i+=2)
{
int a=i,b=i+1;
if(!ask(a,b))swap(a,b);
if(ask(a,mn))mn=a;
if(ask(mx,b))mx=b;
}
cout<<"! "<<mn<<" "<<mn<<" "<<mx<<" "<<N<<endl;
}