QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#324097#4831. Eager Sortinghotboy27030 1ms3848kbC++141.2kb2024-02-10 15:55:032024-02-10 15:55:03

Judging History

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

  • [2024-02-10 15:55:03]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3848kb
  • [2024-02-10 15:55:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1LL)
#define MASK(i) (1LL << (i))
mt19937_64 rng(1);
ll random(ll l,ll r){
    return rng()%(r-l+1)+l;
}
ll myrandom(ll i){
    return rng()%i;
}
ll a[110],b[110];
ll n;
bool ask(ll x,ll y){
    cout<<x<<' '<<y<<endl;
    ll res;
    cin>>res;
    if (res==-1)exit(0);
    if (res)swap(b[x],b[y]);
    return res;
}
bool comp(ll x,ll y){
    assert(x!=y);
    ll id_x,id_y;
    for (ll i = 1;i <= n;i ++){
        if (b[i] == x)id_x=i;
        if (b[i] == y)id_y=i;
    }
    return ask(id_x,id_y) ^ (id_x<id_y);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
    cin>>n;
    if (n==1)return 0;
    for (ll i = 1;i <= n;i ++){
        a[i] = i;
        b[i] = i;
    }
    stable_sort(a+1,a+1+n,comp);
    for (ll i = 1;i <= n;i ++){
        if (a[i] != b[i]){
            for (ll j = i + 1;j <= n;j ++){
                if (b[j] == a[i]){ask(i,j);break;}
            }
        }
    }
}


详细

Test #1:

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

Interactor to First Run

5
0
0
1
1
0
1
1

First Run to Interactor

2 1
2 1
3 1
5 4
5 2
4 2
2 3

Interactor to Second Run

5
0
0
0
0
0
0
0
0

Second Run to Interactor

2 1
2 1
3 1
3 2
5 4
5 4
5 3
4 3

Manager to Checker

OK
good job!

result:

ok OK

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 3580kb

Interactor to First Run

1

First Run to Interactor


Interactor to Second Run


Second Run to Interactor


Manager to Checker

WA
Invalid Operation 1969163480 22014

result:

wrong answer WA