QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#564607#2199. Intriguing SelectionfzxWA 15ms5868kbC++141.2kb2024-09-15 11:19:052024-09-15 11:19:06

Judging History

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

  • [2024-09-15 11:19:06]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:5868kb
  • [2024-09-15 11:19:05]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long 
#define pb push_back
using namespace std;
mt19937 rnd(chrono::system_clock().now().time_since_epoch().count());
int gen(int l,int r) {return rnd()%(r-l+1)+l;}
const int INF=5e5+5;
int n,v3[INF],pre[INF],p[INF];
vector <int> cnt;
void solve() {
    cin>>n;cnt.clear();
    for (int i=0;i<=n*2;i++) pre[i]=0;
    for (int i=1;i<=n*2;i++) p[i]=i;
    for (int i=2;i<=n*2;i++) swap(p[gen(1,i-1)],p[i]);
    for (int i=1;i<=n;i++) {
        int x=p[i],y=p[i+n];
        cout<<"? "<<x<<" "<<y<<endl;
        char c;cin>>c;
        if (c=='<') cnt.pb(x),pre[x]=y;
        else cnt.pb(y),pre[y]=x;
    }
    int T=n;
    while (T--) {
        int len=cnt.size(),x=cnt[0];
        for (int i=1;i<len;i++) {
            cout<<"? "<<cnt[i]<<" "<<x<<endl;
            char c;cin>>c;
            if (c=='<') x=cnt[i];
        }
        vector <int> cnt1;
        for (int i=0;i<len;i++)
            if (cnt[i]==x) ;
            else cnt1.pb(cnt[i]);
        if (!pre[x]) ;
        else cnt1.pb(pre[x]);
        cnt=cnt1;
    }
    cout<<"!"<<endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    int t=0;cin>>t;
    while (t--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5736kb

input:

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

output:

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

result:

ok 2 cases

Test #2:

score: -100
Wrong Answer
time: 15ms
memory: 5868kb

input:

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

output:

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

result:

wrong answer Case 44: all players in topn are comparable