QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#312758#4831. Eager Sortingminhnhatnoe0 0ms0kbC++141.0kb2024-01-24 11:33:162024-01-24 11:33:17

Judging History

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

  • [2024-01-24 11:33:17]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-01-24 11:33:16]
  • 提交

answer

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

int n;

int inter(int i, int j){
    if (i == j) return 0;
    assert(i < j);
    cout << i+1 << " " << j+1 << endl;
    int v; cin >> v;
    if (v == -1) exit(0);
    return v;
}

void recurse(int begin, int end){
    if (begin+1 == end) return;

    int mid = (begin + end)>>1;
    recurse(begin, mid);
    recurse(mid, end);
    if (inter(mid-1, mid) == 0) return;

    deque<int> x, y;
    for (int i=begin; i<mid-1; i++) x.push_back(i);
    x.push_back(mid);

    y.push_back(mid-1);
    for (int i=mid+1; i<end; i++) y.push_back(i);

    for (int i=begin; i<end; i++){
        int posl = x[0], posr = y[0];
        int v = inter(posl, posr);
        inter(i, posl);
        if (v == 0){
            x.pop_front();
        }
        else{
            swap(x[0], y[0]);
            y.pop_front();
        }
    }
}

signed main(){
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    recurse(0, n);

    cout << "-1 -1" << endl;
}

详细

Test #1:

score: 0
Instance #0 Runtime Error

Interactor to First Run

5
0
1

First Run to Interactor

1 2
4 5

Interactor to Second Run

5
0
0
0
1
1
0
1
0
0

Second Run to Interactor

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

Manager to Checker

OK
good job!

result: