QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574129#6394. Turn on the Light123adadWA 1ms3672kbC++20800b2024-09-18 20:52:482024-09-18 20:52:49

Judging History

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

  • [2024-09-18 20:52:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3672kb
  • [2024-09-18 20:52:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2024;
void solve()
{
   int n;cin>>n;
   int l=1,r=n;
   int a=0;
   int x;
   for(int i=1;i<20;i++)
   {
     cout<<"? "<<i<<endl;
     cin>>x;
     if(a==x)
     {
        cout<<"! "<<i<<endl;
        return;
     }
     a=x;
     l=i+1;
   }
   while(l<r)
   {
     int mid=(l+r)>>1;
     cout<<"? "<<mid<<endl;
     cin>>x;
     if(a>x)
     {
        l=mid+1;
     }
     else if(a==x)
     {
        cout<<"! "<<mid<<endl;
        return;
     }
     else
     {
        r=mid;
     }
     a=x;
   }
   if(l==r) cout<<"! "<<l<<endl;

} 
int main()
{
    //ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _=1;//cin>>_;
    while(_--) solve();
    return 0;
}

詳細信息

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
5
6
7
8
8

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
! 9

result:

ok Correct position at 9

Test #3:

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

input:

9
1
2
3
4
5
6
7
7

output:

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

result:

ok Correct position at 8

Test #4:

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

input:

8
1
2
3
4
5
6
6

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
! 7

result:

ok Correct position at 7

Test #5:

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

input:

7
1
2
3
4
5
5

output:

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

result:

ok Correct position at 6

Test #6:

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

input:

6
1
2
3
4
5
5

output:

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

result:

ok Correct position at 6

Test #7:

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

input:

5
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #8:

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

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

score: -100
Wrong Answer
time: 1ms
memory: 3644kb

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 15
? 16
? 17
? 18
? 19
? 500010
? 750005
? 875003
? 937502
? 968751
? 984376
? 992188
? 996094
? 998047
? 999024
? 999512
? 999756
? 999878
? 999939
? 999970
? 999985
? 999993
? 999997
? 999999
! 1000000

result:

wrong answer Wrong answer, more than 1 possible light!