QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#858054#8939. PermutationluuiaWA 0ms3584kbC++14595b2025-01-16 13:39:342025-01-16 13:39:35

Judging History

This is the latest submission verdict.

  • [2025-01-16 13:39:35]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3584kb
  • [2025-01-16 13:39:34]
  • Submitted

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 mid = t * l + (1 - t) * r;
	ll o = query(l,mid);
	if(o == x) {cal(l,mid,o);return;}
	ll p = query(mid + 1,r);cal(mid + 1,r,p);
}

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: 0ms
memory: 3584kb

input:

3
5
3
1
3

output:

? 1 5
? 1 2
? 3 5
? 3 3

result:

wrong answer Integer 3 violates the range [4, 5] (test case 1)