QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371679#6394. Turn on the LightTANGTANGCCWA 1ms3912kbC++23965b2024-03-30 14:55:372024-03-30 14:55:37

Judging History

你现在查看的是最新测评结果

  • [2024-03-30 14:55:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3912kb
  • [2024-03-30 14:55:37]
  • 提交

answer

#include <bits/stdc++.h>
#include <sstream>

//#define int long long
#define endl '\n'
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;

using namespace std;

signed main() {
    int n,x,y;
    cin>>n;
    int a;
    printf("? 1\n");
    cin>>a;
    int l=1,r=n;
    while(l<=r) {
        int m=(l+r)>>1;
        printf("? %d\n",m);
        cin>>x;
        if(x==0 and a==1) {
            a=x;
            r=m-1;
            m=(l+r)>>1;
            printf("? %d\n",l);
            cin>>x;
            if(a==x) {
                printf("! %d",l);
                return 0;
            }
            a=x;
            continue;
        }
        if(x==a) {
            printf("! %d",m);
            return 0;
        }
        else if(x==a+1) {
            l=m+1;
        }
        else if(x==a-1) {
            r=m-1;
        }
        a=x;
    }
    printf("! %d",l);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

10
1
2
3
3

output:

? 1
? 5
? 8
? 9
! 9

result:

ok Correct position at 9

Test #3:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

9
1
2
3
3

output:

? 1
? 5
? 7
? 8
! 8

result:

ok Correct position at 8

Test #4:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

8
1
2
3
3

output:

? 1
? 4
? 6
? 7
! 7

result:

ok Correct position at 7

Test #5:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

7
1
2
3
3

output:

? 1
? 4
? 6
? 7
! 7

result:

ok Correct position at 7

Test #6:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

6
1
2
3
3

output:

? 1
? 3
? 5
? 6
! 6

result:

ok Correct position at 6

Test #7:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

5
1
2
3
3

output:

? 1
? 3
? 4
? 5
! 5

result:

ok Correct position at 5

Test #8:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

score: -100
Wrong Answer
time: 0ms
memory: 3728kb

input:

2
1
1

output:

? 1
? 1
! 1

result:

wrong answer Wrong favorite light!