QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#312711 | #4831. Eager Sorting | minhnhatnoe | 0 | 1ms | 3684kb | C++14 | 1.0kb | 2024-01-24 11:00:40 | 2024-01-24 11:00:40 |
answer
#include <bits/stdc++.h>
using namespace std;
int n;
int inter(int i, int j){
if (i == j) return 0;
if (i > j) swap(i, j);
cout << i+1 << " " << j+1 << endl;
int v; cin >> v;
if (v == -1) exit(0);
return v;
}
void trip(int pos, int c1, int c2){
assert(pos < c1 && c1 < c2);
inter(c1, c2);
inter(pos, c1);
}
void recurse(int begin, int end){
if (begin+1 == end) return;
int mid = (begin + end)>>1;
recurse(begin, mid);
recurse(mid, end);
int ptrl = begin, ptrr = mid;
while (true){
int v = inter(ptrl, ptrr);
ptrl++;
if (v) break;
if (ptrl == mid) return;
}
while (ptrl != mid){
trip(ptrl, ptrr, ptrr+1);
ptrl++;
}
while (ptrr+1 != end){
int v = inter(ptrr, ptrr+1);
if (v == 0) break;
ptrr++;
}
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n;
recurse(0, n);
cout << "-1 -1" << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
Interactor to First Run
5 0 1 0 1 0 1 1 0 -1
First Run to Interactor
1 2 4 5 3 4 1 3 3 4 2 3 3 4 4 5 -1 -1
Interactor to Second Run
5 0 0 0 0 0
Second Run to Interactor
1 2 4 5 3 4 1 3 2 3 -1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #2:
score: 100
Accepted
time: 1ms
memory: 3632kb
Interactor to First Run
1
First Run to Interactor
-1 -1
Interactor to Second Run
1
Second Run to Interactor
-1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #3:
score: 100
Accepted
time: 1ms
memory: 3628kb
Interactor to First Run
2 0
First Run to Interactor
1 2 -1 -1
Interactor to Second Run
2 0
Second Run to Interactor
1 2 -1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #4:
score: 100
Accepted
time: 0ms
memory: 3604kb
Interactor to First Run
2 1
First Run to Interactor
1 2 -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: 3568kb
Interactor to First Run
9 1 0 0 0 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 1 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 5 5 6 3 5 5 6 4 5 5 6 6 7 7 8 8 9 -1 -1
Interactor to Second Run
9 0 0 0 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 -1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #6:
score: 100
Accepted
time: 1ms
memory: 3680kb
Interactor to First Run
9 0 1 1 1 1 1 0 1 1 0 0 1 0 0 0 1 0 1 1 1 1 0
First Run to Interactor
1 2 3 4 1 3 3 4 2 3 3 4 5 6 8 9 7 8 8 9 5 7 6 7 7 8 1 5 2 5 3 5 5 6 4 5 5 6 6 7 7 8 8 9 -1 -1
Interactor to Second Run
9 0 0 0 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 -1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #7:
score: 100
Accepted
time: 1ms
memory: 3628kb
Interactor to First Run
6 0 1 0 1 0 1 1 1 1 1 1 1
First Run to Interactor
2 3 1 2 2 3 5 6 4 5 1 4 4 5 2 4 4 5 3 4 4 5 5 6 -1 -1
Interactor to Second Run
6 0 0 0 1 0 0 0 0
Second Run to Interactor
2 3 1 2 5 6 4 5 5 6 1 4 2 4 3 4 -1 -1
Manager to Checker
OK good job!
result:
ok OK
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 3684kb
Interactor to First Run
20 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0
First Run to Interactor
1 2 4 5 3 4 4 5 1 3 3 4 2 3 3 4 4 5 6 7 9 10 8 9 6 8 8 9 7 8 8 9 9 10 1 6 2 6 3 6 6 7 4 6 6 7 5 6 6 7 7 8 8 9 11 12 14 15 13 14 14 15 11 13 13 14 12 13 13 14 14 15 16 17 19 20 18 19 19 20 16 18 18 19 17 18 18 19 11 16 16 17 12 16 16 17 13 16 16 17 14 16 16 17 15 16 16 17 17 18 18 19 19 20 1 11 11 12...
Interactor to Second Run
20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 0
Second Run to Interactor
1 2 4 5 3 4 1 3 2 3 6 7 9 10 8 9 6 8 7 8 1 6 2 6 3 6 4 6 5 6 11 12 14 15 13 14 11 13 12 13 13 14 14 15 16 17 19 20 18 19 16 18 17 18 11 16 16 17 12 16 16 17 13 16 16 17 14 16 16 17 15 16 16 17 17 18 18 19 1 11 2 11 3 11 4 11 11 12 5 11 11 12 6 11 11 12 7 11 11 12 8 11 11 12 9 11 11 12 10 11 11 12 12...
Manager to Checker
WA array is not sorted!
result:
wrong answer WA