QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#881963 | #8939. Permutation | sugar | WA | 69ms | 3584kb | C++14 | 806b | 2025-02-04 20:06:19 | 2025-02-04 20:06:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
mt19937 myrand(time(0));
int n;
void solve()
{
cin>>n;
int l=1,r=n,la=0;
cout<<'?'<<' '<<1<<' '<<n<<endl;
cin>>la;
while(l!=r)
{
// printf("sure %d-%d\n",l,r);
if(r==l+1)
{
if(l==la)l++;
else r--;
break;
}
int mi=l+(r-l)*5/8;
if(mi<la)mi=l+(r-l)*3/8;
if(mi==l)mi++;
int num=(mi<la);
if(num)cout<<'?'<<' '<<mi+1<<' '<<r<<endl;
else cout<<'?'<<' '<<l<<' '<<mi<<endl;
int pos=0;
cin>>pos;
if(la==pos)
{
if(num) l=mi+1;
else r=mi;
}
else
{
if(num)cout<<'?'<<' '<<l<<' '<<mi<<endl;
else cout<<'?'<<' '<<mi+1<<' '<<r<<endl;
cin>>la;
if(num)r=mi;
else l=mi+1;
}
}
cout<<'!'<<' '<<l<<endl;
}
int main()
{
int tt=0;
cin>>tt;
while(tt--)solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3456kb
input:
3 5 3 2 5 6 6 3 1 4 3 3
output:
? 1 5 ? 1 3 ? 4 5 ! 4 ? 1 6 ? 3 6 ? 1 2 ! 2 ? 1 4 ? 3 4 ! 4
result:
ok Correct (3 test cases)
Test #2:
score: 0
Accepted
time: 69ms
memory: 3584kb
input:
10000 10 2 2 2 1 3 10 10 10 7 5 10 5 1 10 9 8 10 4 4 4 4 10 10 6 3 4 2 10 3 3 3 4 2 10 1 5 9 10 7 10 1 3 8 8 10 2 4 9 9 10 3 3 3 3 10 4 1 7 8 9 10 8 7 1 2 4 10 4 1 9 9 10 7 7 7 8 6 10 5 1 7 8 10 10 8 8 6 9 10 2 2 1 5 10 6 4 10 10 10 1 3 8 8 10 7 9 4 4 10 7 8 4 4 10 3 4 7 8 10 10 4 4 1 6 10 8 7 4 3 2...
output:
? 1 10 ? 1 6 ? 1 4 ? 1 2 ? 3 4 ! 4 ? 1 10 ? 5 10 ? 7 10 ? 5 6 ! 6 ? 1 10 ? 1 6 ? 7 10 ? 9 10 ? 7 8 ! 7 ? 1 10 ? 1 6 ? 1 4 ? 3 4 ! 3 ? 1 10 ? 5 10 ? 1 4 ? 3 4 ? 1 2 ! 1 ? 1 10 ? 1 6 ? 1 4 ? 3 4 ? 1 2 ! 1 ? 1 10 ? 1 6 ? 7 10 ? 9 10 ? 7 8 ! 8 ? 1 10 ? 1 6 ? 7 10 ? 7 8 ! 7 ? 1 10 ? 1 6 ? 7 10 ? 9 10 ! 1...
result:
ok Correct (10000 test cases)
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 3584kb
input:
10000 3 1 2
output:
? 1 3 ? 1 2 ? 3 3
result:
wrong answer Integer 3 violates the range [1, 2] (test case 1)