結果

問題 No.2978 Lexicographically Smallest and Largest Subarray
ユーザー karinohito
提出日時 2024-12-02 19:46:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 675 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 199,168 KB
最終ジャッジ日時 2025-02-26 10:39:22
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 57
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int N,Q,x,p,q;
int ask(int l,int r){
    cout<<"? "<<l<<" "<<N<<" "<<r<<" "<<N<<endl;
    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){
        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){
            p=B[i].front();
            B[i].pop();
            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";
}
0