QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#456094#4831. Eager Sortingbiank230 1ms3764kbC++141.9kb2024-06-27 10:25:582024-06-27 10:25:59

Judging History

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

  • [2024-06-27 10:25:59]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3764kb
  • [2024-06-27 10:25:58]
  • 提交

answer

#include <bits/stdc++.h>
 
using namespace std;
 
#define sz(x) int(x.size())
#define all(x) begin(x),end(x)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)
#define dbg(x) cerr<<#x<<": "<<x<<endl
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
 
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
 
//const int MAXN = 2e5+5;
//const ll INF = 1e18;
const int MOD = 1e9+7;
 
template<class x> ostream & operator<<(ostream & out, vector<x> v){
    out<<"[ ";
    for(auto y : v) out<<y<<" ";
    out<<"]";
    return out;
}
 
template<class a, class b> ostream & operator<<(ostream & out, pair<a, b> p){
    return out<<"("<<p.fst<<", "<<p.snd<<")";
}

vi p,p2;

bool cmp(int x, int y){//x<y
    cout<<p[x]+1<<' '<<p[y]+1<<endl;
    int r; cin>>r;
    if(r==-1)exit(0);
    if(r==1){
        swap(p[x],p[y]);
        p2[p[x]]=x,p2[p[y]]=y;
        return false;
    }
    return true;
}

vi merge(const vi &a, const vi &b){
    int n=sz(a),m=sz(b);
    vi c(n+m);
    int i=0,j=0;
    forn(k,n+m){
        if(j>=m||(i<n&&cmp(a[i],b[j]))) c[k]=a[i++];
        else c[k]=b[j++];
    }
    return c;
}

void merge_sort(vi &v){
    int n=sz(v);
    if(n<=1) return;
    vi a(begin(v),begin(v)+n/2);
    vi b(begin(v)+n/2,end(v));
    merge_sort(a);
    merge_sort(b);
    v=merge(a,b);
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n;
    cin>>n;
    vi a(n); iota(all(a),0);
    p.resize(n); iota(all(p),0);
    p2.resize(n); iota(all(p2),0);
    merge_sort(a);
    forn(i,n) cmp(p2[i],p[a[i]]);
    cout<<"-1 -1"<<endl;
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

Interactor to First Run

5
0
1
0
1
0
1
0
0
-1

First Run to Interactor

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

Interactor to Second Run

5
0
0
0
0
1
0
0
0
0
0
0

Second Run to Interactor

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

Manager to Checker

OK
good job!

result:

ok OK

Test #2:

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

Interactor to First Run

1
0

First Run to Interactor

1 1
-1 -1

Interactor to Second Run

1
0

Second Run to Interactor

1 1
-1 -1

Manager to Checker

OK
good job!

result:

ok OK

Test #3:

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

Interactor to First Run

2
0
0
0

First Run to Interactor

1 2
1 1
2 2
-1 -1

Interactor to Second Run

2
0
0
0

Second Run to Interactor

1 2
1 1
2 2
-1 -1

Manager to Checker

OK
good job!

result:

ok OK

Test #4:

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

Interactor to First Run

2
1
0
0

First Run to Interactor

1 2
1 2
2 1
-1 -1

Interactor to Second Run

2
0
-1

Second Run to Interactor

1 2
1 1

Manager to Checker

OK
good job!

result:

ok OK

Test #5:

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

Interactor to First Run

9
1
0
0
0
1
0
1
1
0
0
1
0
0
0
1
1
1
0
0
0
1
0
0
0
0
0
0

First Run to Interactor

1 2
3 4
1 3
2 3
5 6
8 9
7 8
8 9
5 7
6 7
1 5
5 6
2 6
3 6
4 6
6 7
7 8
8 9
1 2
2 4
3 5
4 4
5 8
6 1
7 9
8 6
9 7
-1 -1

Interactor to Second Run

9
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0

Second Run to Interactor

1 2
3 4
1 3
2 3
3 4
5 6
8 9
7 8
5 7
6 7
1 5
2 5
3 5
4 5
5 6
1 1
2 3
3 2
4 5
5 4
6 6
7 7
8 8
9 9
-1 -1

Manager to Checker

OK
good job!

result:

ok OK

Test #6:

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

Interactor to First Run

9
0
1
1
1
0
1
1
0
0
1
0
0
0
1
0
1
1
1
0
0
1
0
0
0
0
0
0
0

First Run to Interactor

1 2
3 4
1 3
3 4
5 6
8 9
7 8
8 9
5 7
6 7
7 8
1 5
3 5
4 5
5 6
2 6
6 7
7 8
8 9
1 5
2 3
3 1
4 4
5 2
6 6
7 7
8 9
9 3
-1 -1

Interactor to Second Run

9
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0

Second Run to Interactor

1 2
3 4
1 3
2 3
5 6
8 9
7 8
5 7
6 7
1 5
2 5
3 5
4 5
5 6
1 1
2 2
3 5
4 3
5 4
6 6
7 7
8 8
9 9
-1 -1

Manager to Checker

OK
good job!

result:

ok OK

Test #7:

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

Interactor to First Run

6
0
1
0
1
0
1
1
0
1
0
0
0
0
0
1

First Run to Interactor

2 3
1 2
2 3
5 6
4 5
1 4
4 5
5 6
2 6
1 6
2 1
3 2
4 5
5 4
6 3
-1 -1

Interactor to Second Run

6
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0

Second Run to Interactor

2 3
1 2
5 6
4 5
1 4
2 4
4 5
5 6
3 6
1 1
2 5
3 2
4 4
5 3
6 6
-1 -1

Manager to Checker

WA
array is not sorted!

result:

wrong answer WA