QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#858083 | #8939. Permutation | luuia | WA | 1ms | 3584kb | C++14 | 758b | 2025-01-16 13:56:24 | 2025-01-16 13:57:10 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 10;
const double t = 0.618;
ll T,n,m,o,s,l,r,L,R;
ll query(ll l,ll r)
{
ll o;cout << "? " << l << " " << r << '\n';
cin >> o;return o;
}
void cal(ll l,ll r,ll x)
{
if(l == r){cout << "! " << l << '\n';return;}
ll o1 = l - 1 + (r - l + 1) * t,o2 = ceil(r - (r - l + 1) * t + 1);
if(o1 < x && o2 > x) o1++;
if(x <= o1)
{
if(query(l,o1) == x) cal(l,o1,x);
else cal(o1 + 1,r,query(o1 + 1,r));
}
else
{
if(query(o2,r) == x) cal(o2,r,x);
else cal(l,o2 - 1,query(l,o2 - 1));
}
}
void sol(){cin >> n,s = query(1,n),cal(1,n,s);}
int main()
{
// freopen("input.in","r",stdin);
cin >> T;while(T--) sol();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3584kb
input:
3 5 3 2 5
output:
? 1 5 ? 1 3 ? 4 5 ? 5 5
result:
wrong answer Integer 5 violates the range [1, 4] (test case 1)