QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#555660 | #8939. Permutation | alexz1205 | WA | 1ms | 3948kb | C++14 | 1011b | 2024-09-10 07:44:47 | 2024-09-10 07:44:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr double phi = (1+sqrt(5))/2;
constexpr double phiRat = 1/((1+sqrt(5))/2);
int getSecond(int l, int r){
if (l+1 == r){
return l;
}
printf("? %d %d\n", l+1, r);
fflush(stdout);
int ind;
scanf("%d", &ind);
return ind-1;
}
int ran(int l, int r, int ind){
if (l+1 == r){
return ind;
}
if (r-l == 2){
return l + (ind == l);
}
int len = r-l-(int)((double)(r-l) * phiRat);
if (ind >= l + len){
int res = getSecond(r-len, r);
if (res == ind){
return ran(r-len, r, ind);
}else {
return ran(l, r-len, getSecond(l, r-len));
}
}else {
int res = getSecond(l, l+len);
if (res == ind){
return ran(l, l+len, ind);
}else {
return ran(l+len, r, getSecond(l+len, r));
}
}
}
void solve(){
int n;
scanf("%d", &n);
printf("! %d\n", 1+ran(0, n, getSecond(0, n)));
fflush(stdout);
}
int main(){
int t;
scanf("%d", &t);
for (int x = 0; x < t; x ++){
solve();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3948kb
input:
3 5 3 5 2 1
output:
? 1 5 ? 4 5 ? 1 3 ? 1 2 ! 3
result:
wrong answer Wrong prediction (test case 1)