QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#521409#2199. Intriguing Selectionbachbeo2007WA 19ms3688kbC++23941b2024-08-16 10:11:332024-08-16 10:11:33

Judging History

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

  • [2024-08-16 10:11:33]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:3688kb
  • [2024-08-16 10:11:33]
  • 提交

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: 100
Accepted
time: 1ms
memory: 3688kb

input:

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

output:

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

result:

ok 2 cases

Test #2:

score: -100
Wrong Answer
time: 19ms
memory: 3596kb

input:

1111
3
>
>
<
>
<
<
<
>
<
<
>
>
3
<
>
>
>
<
>
>
>
>
>
<
<
3
>
<
<
>
<
>
<
>
>
>
>
>
3
<
>
<
<
<
>
<
<
>
>
<
>
3
>
<
<
>
>
>
<
>
<
>
>
>
3
<
>
<
>
<
>
<
>
<
<
>
>
3
<
>
<
<
>
<
>
<
>
<
>
<
3
>
<
<
>
<
>
<
>
<
<
>
>
3
<
>
>
>
<
<
>
>
>
<
<
>
3
<
>
>
<
>
<
>
>
<
>
>
<
3
<
<
>
<
>
<
<
>
>
<
<
<
3
>
<
>
>...

output:

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

result:

wrong answer Case 28: all players in topn are comparable