QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#858070#8939. PermutationluuiaWA 1ms3584kbC++14676b2025-01-16 13:49:412025-01-16 13:49:52

Judging History

This is the latest submission verdict.

  • [2025-01-16 13:49:52]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3584kb
  • [2025-01-16 13:49:41]
  • 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);
	// cout << o << " " << x << " " << l << " " << mid << " " << r << '\n';
	if(o == x) {cal(l,mid,o);return;}
	else {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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
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)