QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#686508#6394. Turn on the Lightlibantian#WA 1ms3704kbC++231.1kb2024-10-29 13:55:532024-10-29 13:55:53

Judging History

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

  • [2024-10-29 13:55:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3704kb
  • [2024-10-29 13:55:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(), _a.end()

// void solve(int l,int r,int y){
//     int x;
//     printf("? %d\n",r);
//     scanf("%d",&x);
//     if (x==y) {printf("! %d\n",r); exit(0);}
//     y=x;
//     int mid=l+r>>1;
//     printf("? %d\n",mid);
//     scanf("%d",&x);
//     if (x==y) {printf("! %d\n",mid); exit(0);}
//     if (x==y+1) solve(l,mid-1,x); else solve(mid+1,r,x);
// }
void solve(int l,int r,int y){
    int x;
    cout<<"? "<<r<<endl;
    cin>>x;
    if (x==y) {cout<<"! "<<r<<endl; exit(0);}
    y=x;
    int mid=l+r>>1;
    cout<<"? "<<mid<<endl;
    cin>>x;
    if (x==y) {cout<<"! "<<mid<<endl; exit(0);}
    if (x==y+1) solve(l,mid-1,x); else solve(mid+1,r,x);
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << setiosflags(ios::fixed) << setprecision(15);
    int T;
    T=1;
    //cin>>T;
    int n;
    cin>>n;
    solve(1,n,0);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0

output:

? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
0
0

output:

? 10
? 5
? 10
! 10

result:

wrong answer Wrong answer, more than 1 possible light!