QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#108190#6394. Turn on the LightLiberty12619#WA 3ms3568kbC++201.0kb2023-05-23 20:21:302023-05-23 20:21:32

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:21:32]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3568kb
  • [2023-05-23 20:21:30]
  • 提交

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(r-l>1)
    {
        int mid = l+r>>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;
        last=t;
    }
    if(l==r)cout<<"! "<<l<<endl;
    else
    {
        if(query(l)==last)  cout<<"! "<<l<<endl;
        else    cout<<"! "<<r<<endl;
    }
}
signed main()
{
    int T =1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

input:

3
1
2

output:

? 2
? 1
! 3

result:

ok Correct position at 3

Test #2:

score: 0
Accepted
time: 2ms
memory: 3448kb

input:

10
1
2
3
4
5

output:

? 5
? 1
? 8
? 6
? 9
! 10

result:

ok Correct position at 10

Test #3:

score: 0
Accepted
time: 2ms
memory: 3436kb

input:

9
1
2
3
4
5

output:

? 5
? 1
? 7
? 6
? 8
! 9

result:

ok Correct position at 9

Test #4:

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

input:

8
1
2
3
4
5

output:

? 4
? 1
? 6
? 5
? 7
! 8

result:

ok Correct position at 8

Test #5:

score: 0
Accepted
time: 2ms
memory: 3436kb

input:

7
1
2
3
4

output:

? 4
? 1
? 6
? 5
! 7

result:

ok Correct position at 7

Test #6:

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

input:

6
1
2
3
4

output:

? 3
? 1
? 5
? 4
! 6

result:

ok Correct position at 6

Test #7:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

5
1
2
3

output:

? 3
? 1
? 4
! 5

result:

ok Correct position at 5

Test #8:

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

input:

4
1
2
3

output:

? 2
? 1
? 3
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 2
? 1
! 1

result:

ok Correct position at 1

Test #10:

score: 0
Accepted
time: 3ms
memory: 3388kb

input:

2
1

output:

? 1
! 2

result:

ok Correct position at 2

Test #11:

score: 0
Accepted
time: 2ms
memory: 3428kb

input:

1

output:

! 1

result:

ok Correct position at 1

Test #12:

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

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
31
32
31
30
29

output:

? 500000
? 1
? 750000
? 500001
? 875000
? 750001
? 937500
? 875001
? 968750
? 937501
? 984375
? 968751
? 992188
? 984376
? 996094
? 992189
? 998047
? 996095
? 999024
? 998048
? 999512
? 999025
? 999756
? 999513
? 999878
? 999757
? 999939
? 999879
? 999970
? 999940
? 999985
? 999971
? 999993
? 999986...

result:

wrong answer Wrong answer, more than 1 possible light!