結果

問題 No.3591 I Love Graph
コンテスト
ユーザー yuunegi
提出日時 2026-07-17 22:08:14
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 1,297 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,167 ms
コンパイル使用メモリ 340,776 KB
実行使用メモリ 5,888 KB
平均クエリ数 2979.06
最終ジャッジ日時 2026-07-17 22:08:37
合計ジャッジ時間 6,590 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    stack<array<int,4>>st;
    vector<array<int,2>>ans;
    for(int i=n-2;i>=0;i--){
        st.push({i,i+1,n-1,0});
    }
    int q=0;
    while(!st.empty()){
        array<int,4>tmp=st.top();
        st.pop();
        if(q>4500)return 1;
        q++;
        cout<<"? 1 "<<tmp[2]-tmp[1]+1<<" "<<tmp[0]+1<<" ";
        for(int i=tmp[1];i<=tmp[2];i++){
            cout<<i+1<<(i!=tmp[2]?" ":"");
        }
        cout<<endl;
        int a;
        cin>>a;
        if(a==-1)return 1;
        if(a){
            if(tmp[2]==tmp[1]){
                ans.push_back({tmp[0],tmp[1]});
            }else{
                st.push({tmp[0],tmp[1],(tmp[1]+tmp[2])/2,0});
                st.push({tmp[0],(tmp[1]+tmp[2])/2+1,tmp[2],1});
            }
        }else if(tmp[3]==1){
            tmp=st.top();
            st.pop();
            if(tmp[2]==tmp[1]){
                ans.push_back({tmp[0],tmp[1]});
            }else{
                st.push({tmp[0],tmp[1],(tmp[1]+tmp[2])/2,0});
                st.push({tmp[0],(tmp[1]+tmp[2])/2+1,tmp[2],1});
            }
        }
    }
    cout<<"! "<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout<<ans[i][0]+1<<" "<<ans[i][1]+1<<endl;
    }
    return 0;
}
0