QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371746#6394. Turn on the Lighthuangxi#WA 1ms3804kbC++17877b2024-03-30 15:25:232024-03-30 15:25:23

Judging History

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

  • [2024-03-30 15:25:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3804kb
  • [2024-03-30 15:25:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef long long LL;
const int N=1e3+10,M=510;
int n,m;
pair<int,int>a[N],b[N];
bool flag;
int x;
int query(int x){
    int cur;
    cout<<"? "<<x<<endl;
    cout.flush();
    cin>>cur;
    return cur;
}

int main() {
    scanf("%d",&n);
    int l=1,r=n;
    int pe=0;
    while(l<=r){
        if(pe==0){
            int cur=query(l);
            if(cur==pe){
                cout<<"! "<<l<<endl;cout.flush();break;
            }
            l++;
            pe=cur;
        }
        int mid=l+r>>1;
        int cur=query(mid);
        if(cur==pe-1){
            r=mid-1;
        }else if(cur==pe){
            cout<<"! "<<l<<endl;
            cout.flush();
            break;
        }else {
            l=mid+1;
        }
        pe=cur;
    }


}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3804kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
0
1
0
0

output:

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

result:

ok Correct position at 3

Test #3:

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

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: 3692kb

input:

8
1
0
1
1

output:

? 1
? 5
? 2
? 3
! 3

result:

ok Correct position at 3

Test #5:

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

input:

7
1
2
3
3

output:

? 1
? 4
? 6
? 7
! 7

result:

ok Correct position at 7

Test #6:

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

input:

6
1
0
1
1

output:

? 1
? 4
? 2
? 3
! 3

result:

ok Correct position at 3

Test #7:

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

input:

5
1
2
3
3

output:

? 1
? 3
? 4
? 5
! 5

result:

ok Correct position at 5

Test #8:

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

input:

4
1
1

output:

? 1
? 3
! 2

result:

wrong answer Wrong favorite light!