QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#521457#2199. Intriguing SelectionsocpiteWA 39ms3840kbC++231.6kb2024-08-16 11:02:302024-08-16 11:02:30

Judging History

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

  • [2024-08-16 11:02:30]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:3840kb
  • [2024-08-16 11:02:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int maxn = 205;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> g[maxn], rg[maxn];

bool vis[maxn];
bool asked[maxn][maxn];

void dfs(int x, int &cnt){
    vis[x] = 1;
    cnt++;
    for(auto v: g[x])if(!vis[v])dfs(v, cnt);
}

void rdfs(int x, int &cnt){
    vis[x] = 1;
    cnt++;
    for(auto v: rg[x])if(!vis[v])rdfs(v, cnt);
}

bool query(int a, int b){
    cout << "? " << a << " " << b << endl;
    char c;
    cin >> c;
    return c == '<';
}

void solve_3(){
    int arr[4] = {1, 2, 3, 0};
    // arr[0] < arr[1], arr[2] < arr[3]
    for(int i = 4; i <= 6; i++){
        for(int j = 0; j < 4; j++)if(!arr[j])arr[j] = i;
        if(!query(arr[0], arr[1]))swap(arr[0], arr[1]);
        if(!query(arr[2], arr[3]))swap(arr[2], arr[3]);
        if(query(arr[0], arr[2]))arr[0] = 0;
        else arr[2] = 0; 
    }
    cout << "!" << endl;
}

struct cmp{
    bool operator()(const int &lhs, const int &rhs)const{
        return !query(lhs, rhs);
    }
};

int main() {
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        if(n == 3){
            solve_3();
            continue;
        }
        memset(vis, 0, sizeof(vis));
        vector<int> P(2*n);
        iota(P.begin(), P.end(), 1);
        shuffle(P.begin(), P.end(), rng);
        priority_queue<int, vector<int>, cmp> pq;
        for(auto v: P){
            pq.push(v);
            if(pq.size() > n)pq.pop();
        }
        cout << "!" << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

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

result:

ok 2 cases

Test #2:

score: 0
Accepted
time: 39ms
memory: 3676kb

input:

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

output:

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

result:

ok 1111 cases

Test #3:

score: -100
Wrong Answer
time: 17ms
memory: 3644kb

input:

625
4
<
>
>
<
>
<
>
>
<
>
<
>
>
<
>
<
>
>
<
>
>
>
>
<
4
>
<
>
<
<
>
>
<
>
>
>
>
<
>
>
>
>
<
>
>
>
>
<
4
<
<
>
<
<
>
>
<
<
>
>
<
>
<
>
>
<
>
>
>
>
<
4
>
<
<
<
<
<
<
>
<
>
<
<
<
>
<
>
>
<
4
<
<
<
<
>
>
<
>
<
>
>
<
>
<
<
<
>
>
>
>
<
4
>
<
>
<
>
>
>
>
<
>
<
>
>
<
>
>
>
>
<
>
>
>
>
<
4
<
<
<
>
<
>
>
<
<
...

output:

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

result:

wrong answer Case 3: all players in topn are comparable