QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#881966#8939. PermutationsugarWA 93ms3712kbC++14884b2025-02-04 20:09:322025-02-04 20:09:33

Judging History

This is the latest submission verdict.

  • [2025-02-04 20:09:33]
  • Judged
  • Verdict: WA
  • Time: 93ms
  • Memory: 3712kb
  • [2025-02-04 20:09:32]
  • Submitted

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 
			{
				if(mi+1==r)
				{
					l=r;
					break;
				}
				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: 1ms
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: 93ms
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: 4ms
memory: 3712kb

input:

10000
3
1
2
11
5
5
5
4
7
2
2
19
3
3
4
12
12

output:

? 1 3
? 1 2
! 3
? 1 11
? 1 7
? 4 7
? 4 5
? 6 7
! 6
? 1 2
! 1
? 1 19
? 1 12
? 1 7
? 8 12
? 10 12
? 12 12

result:

wrong answer Integer 12 violates the range [13, 19] (test case 4)