QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#336621#2199. Intriguing SelectionMilanWA 0ms3612kbC++231.4kb2024-02-24 18:26:382024-02-24 18:26:39

Judging History

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

  • [2024-02-24 18:26:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-02-24 18:26:38]
  • 提交

answer

#include <bits/stdc++.h>
#define MULTI int _; cin >> _; while(_--)
#define fi first
#define se second
#define pb(a) push_back(a)
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, n, m) for(int i = n; i <= m; i++)
#define repsv(i, n, m) for(int i = n; i >= m; i--)
#define vsz(a) (int)(a.size())
#define mp(a, b) make_pair(a, b)
#define all(a) a.begin(), a.end()

using namespace std;

typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;

#ifdef LOCAL
#include "debugs.hpp"
#else
#define dbg(...) 0
#endif

int n;
vi a;

bool ask(int x, int y){
    cout << "? " << x << ' ' << y << '\n';
    char in;
    cin >> in;
    return in == '<';
}

int cmp(int l, int r){
    if(l==r) return a[l];
    else{
        int m = (l+r)/2;
        int v1 = cmp(l, m);
        int v2 = cmp(m+1, r);
        if(v1 != -1) swap(v1, v2);
        if(v1 == -1 && v2 == -1)
            return -1;
        if(v1 == -1)
            return v2;
        if(ask(v1, v2))
            return v1;
        else
            return v2;
    }
}

void solve(){
    cin >> n;
    n *= 2;
    a = vi(n);
    rep(i, n) a[i] = i+1;
    rep(i, n/2){
        int noob = cmp(0, n-1);
        a[noob-1] = -1; 
    }
    cout << "!\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    MULTI
    solve();
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

wrong answer Case 0: all players in topn are comparable