QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#251984#6394. Turn on the Lightucup-team1074WA 1ms3432kbC++171.1kb2023-11-15 14:01:312023-11-15 14:01:31

Judging History

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

  • [2023-11-15 14:01:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3432kb
  • [2023-11-15 14:01:31]
  • 提交

answer

#include<iostream>
#include<math.h>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<queue>
#include<string.h>
#include<stack>
#define ll long long
using namespace std;
int a[100010];
int b[100010];

void solve() 
{
	int n;
    cin>>n;
    int l=2,r=n;
    int res1=0;
    int res2=0;
    int len=0;
    int ans[50];
    cout<<"? "<<1<<endl;
    ++len;
    cin>>ans[len];
    if(ans[len]==0)
    {
        cout<<"! "<<1<<endl;
    }
    else
    while(1)
    {
        int mid =(l+r)>>1;
        cout<<"? "<<mid<<endl;
        ++len;
        cin>>ans[len];
        if(ans[len]==ans[len-1])
        {
            cout<<"! "<<mid<<endl;
            break;

        }
            
        else if(ans[len]>ans[len-1])
        {
            l=mid+1;
        }
        else
        {
            r=mid-1;
        }
    }


}  

int main()
{
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t;
    t=1;
    while(t>0)
    {
        t--;
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
0
1
2
3
3

output:

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

result:

wrong answer Wrong favorite light!