QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#608028#8939. PermutationzzlWA 47ms3640kbC++17712b2024-10-03 17:56:202024-10-03 17:56:20

Judging History

This is the latest submission verdict.

  • [2024-10-03 17:56:20]
  • Judged
  • Verdict: WA
  • Time: 47ms
  • Memory: 3640kb
  • [2024-10-03 17:56:20]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,l,r;
int qu(int l,int r) {
    cout<<'?'<<' '<<l<<' '<<r<<endl;
    cout.flush();
    int tem;
    cin>>tem;
    return tem;
}
int work(int l,int r,int s) {
    if(l==r)return l;
    if(s==0)s=qu(l,r);
    if(l==r-1)return s==l?r:l;
    int mid=l+(0.6*(r-l));
    if(r-s>=s-l) {
        if(qu(l,mid)==s)return work(l,mid,s);
        else return work(mid+1,r,0);
    }
    else {
        if(qu(mid,r)==s)return work(mid,r,s);
        else return work(l,mid-1,0);
    }
}
signed main() {
    int t;
    cin>>t;
    while(t--) {
        cin>>n;
        n=work(1,n,0);
        cout<<'!'<<' '<<n<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

input:

3
5
3
2
5
6
6
5
3
3
4
3
3
2

output:

? 1 5
? 1 3
? 4 5
! 4
? 1 6
? 4 6
? 1 3
? 2 3
! 2
? 1 4
? 2 4
? 2 3
! 4

result:

ok Correct (3 test cases)

Test #2:

score: 0
Accepted
time: 47ms
memory: 3584kb

input:

10000
10
2
2
2
1
3
10
10
10
8
7
10
5
1
10
9
10
4
4
6
2
1
10
10
6
3
3
2
10
3
3
3
2
10
1
5
9
9
9
10
1
3
8
8
10
2
4
9
9
8
10
3
3
3
3
2
10
4
1
7
8
9
10
8
7
1
1
2
10
4
1
9
9
8
10
7
8
2
1
4
10
5
1
7
8
10
10
8
8
6
9
10
2
2
1
5
10
6
6
8
10
10
1
3
8
8
10
7
9
5
5
4
10
7
8
4
4
4
10
3
4
7
8
10
10
4
4
4
4
10
8
7...

output:

? 1 10
? 1 6
? 1 4
? 1 2
? 3 4
! 4
? 1 10
? 6 10
? 8 10
? 6 7
! 6
? 1 10
? 1 6
? 7 10
? 8 10
! 7
? 1 10
? 1 6
? 4 6
? 1 3
? 1 2
! 3
? 1 10
? 6 10
? 1 5
? 1 3
? 2 3
! 1
? 1 10
? 1 6
? 1 4
? 2 4
! 1
? 1 10
? 1 6
? 7 10
? 8 10
? 8 9
! 8
? 1 10
? 1 6
? 7 10
? 7 8
! 7
? 1 10
? 1 6
? 7 10
? 8 10
? 8 9
! 1...

result:

ok Correct (10000 test cases)

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3620kb

input:

10000
3
1
2
11
5
5
5
4
7
2
2
19
3
3
4
11
11
11
7
5
7
1
2
3
3
3
19
6
6
6
7
1
2
2
2
15
11
11
11
12
14
1
1
1
3
5
16
4
4
4
4
5
3
3
2
19
13
17
5
5
6
2
1
2
2
4
1
2
3
7
2
2
2
3
2
2
17
1
1
1
2
6
14
9
9
9
8
11
20
9
9
9
8
11
6
4
4
5
18
7
7
7
7
7
8
8
6
3
3
2
8
6
7
1
2
3
16
10
16
1
3
6
7

output:

? 1 3
? 1 2
! 3
? 1 11
? 1 7
? 4 7
? 4 5
? 6 7
! 6
? 1 2
! 1
? 1 19
? 1 11
? 1 7
? 8 11
? 9 11
? 10 11
! 10
? 1 7
? 4 7
? 1 3
? 1 2
! 3
? 1 3
? 2 3
! 2
? 1 19
? 1 11
? 1 7
? 4 7
? 1 3
? 1 2
! 3
? 1 2
! 1
? 1 15
? 9 15
? 9 12
? 10 12
! 9
? 1 14
? 1 8
? 1 5
? 1 3
? 4 5
! 4
? 1 16
? 1 10
? 1 6
? 4 6
? ...

result:

wrong answer Too many queries , n = 16 , now_q 7 (test case 25)