QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#312758 | #4831. Eager Sorting | minhnhatnoe | 0 | 0ms | 0kb | C++14 | 1.0kb | 2024-01-24 11:33:16 | 2024-01-24 11:33:17 |
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!