QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#108185#6394. Turn on the LightLiberty12619#WA 3ms3616kbC++20926b2023-05-23 20:09:292023-05-23 20:10:55

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-23 20:10:55]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3616kb
  • [2023-05-23 20:09:29]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
const int N = 2e5+10,M = 1<<24,mod = 1e9+7,INF=1e9;
typedef pair<int,int>PII;
int query(int x)
{
    int res;
    cout<<"? "<<x<<endl;
    cin>>res;
    return res;
}
void solve()
{
    int n;
    cin>>n;
    int l=1,r=n,last=0;
    while(l<r)
    {
        int mid = l+r+1>>1;
        int t = query(mid);
        if(t==last)
        {
            cout<<"! "<<mid<<endl;
            return;
        }
        last=t;
        t = query(l);
        if(t==last)
        {
            cout<<"! "<<l<<endl;
            return;
        }
        if(t==last-1)
        {
            l++;
            r=mid-1;
        }
        else    l=mid+1;
    }
    cout<<"! "<<l<<endl;
}
signed main()
{
    int T =1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3616kb

input:

3
1
2

output:

? 2
? 1
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3316kb

input:

10
1
0
1

output:

? 6
? 1
? 4
! 4

result:

wrong answer Wrong answer, more than 1 possible light!