QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#521406#2199. Intriguing Selectionbachbeo2007WA 0ms3876kbC++23939b2024-08-16 10:10:302024-08-16 10:10:31

Judging History

你现在查看的是最新测评结果

  • [2024-08-16 10:10:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3876kb
  • [2024-08-16 10:10:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
bool ask(int x,int y){
    cout << "? " << x << ' ' << y << endl;
    char c;cin >> c;return (c=='<');
}

void solve(){
    int n;cin >> n;
    vector<int> a(2*n);
    iota(a.begin(),a.end(),1);
    shuffle(a.begin(),a.end(),rng);
    function<int(int,int)> get = [&](int l,int r){
        if(l+1==r) return a[l];
        int mid=(l+r)>>1;
        int x=get(l,mid),y=get(mid,r);
        if(x==-1) return y;
        else if(y==-1) return x;
        else return y+ask(x,y)*(x-y);
    };
    for(int i=0;i<n;i++){
        int id=get(0,2*n);
        for(int j=0;j<2*n;j++) if(a[j]==id) a[j]=-1;
        a[id-1]=-1;
    }
    cout << "!" << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int test;cin >> test;
    while(test--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3876kb

input:

2
3
<
>
<
>
>
<
>
>
<
>
3
>
>
>
>
>
>
>
<
<

output:

? 3 1
? 2 3
? 6 4
? 5 6
? 3 6
? 3 1
? 2 3
? 3 5
? 3 1
? 2 3
!
? 3 5
? 2 5
? 4 1
? 6 1
? 5 1
? 3 5
? 6 4
? 5 4
? 3 6
!

result:

wrong answer Case 0: the top n are not uniquely determined: 4 is not compared to 1