QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#574176#6394. Turn on the Light123adadWA 1ms3728kbC++20799b2024-09-18 20:59:442024-09-18 20:59:47

Judging History

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

  • [2024-09-18 20:59:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2024-09-18 20:59:44]
  • 提交

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;
   for(int i=1;i<15;i++)
   {
     cout<<"? "<<i<<endl;
     int b;cin>>b;
     if(a==b)
     {
        cout<<"! "<<i<<endl;
        return;
     }
     a=b;
     l=i+1;
   }
   while(l<r)
   {
     int mid=l+r>>1;
     cout<<"? "<<mid<<endl;
     int x;cin>>x;
     if(x>a)
     {
        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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
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: 3668kb

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: 3676kb

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: 3640kb

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: 3656kb

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: 0ms
memory: 3668kb

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: 3712kb

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: 3656kb

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: 3644kb

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

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
11
10
11
10
10

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500007
? 750004
? 875002
? 937501
? 968751
? 984376
? 976564
? 972658
? 970705
? 969728
? 969240
? 968996
? 968874
? 968813
? 968782
? 968798
? 968790
? 968794
? 968792
! 968792

result:

ok Correct position at 968792

Test #13:

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

input:

999999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
12
11
10
11
10
9
8
7
6
5
4
3
2
3
2
3
2
2

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500007
? 250011
? 125013
? 62514
? 31264
? 46889
? 39077
? 35171
? 33218
? 32241
? 31753
? 31509
? 31387
? 31326
? 31295
? 31311
? 31303
? 31307
? 31305
! 31305

result:

ok Correct position at 31305

Test #14:

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

input:

999998
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
11
10
11
10
10

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500006
? 750002
? 875000
? 937499
? 968749
? 984374
? 976562
? 972656
? 970703
? 969726
? 969238
? 968994
? 968872
? 968811
? 968780
? 968796
? 968788
? 968792
? 968790
! 968790

result:

ok Correct position at 968790

Test #15:

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

input:

999997
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
14
15
16
15
14
13
12
11
10
9
8
7
6
7
6
7
6
6

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500006
? 250010
? 375008
? 437507
? 468757
? 453132
? 445320
? 441414
? 439461
? 438484
? 437996
? 437752
? 437630
? 437569
? 437538
? 437554
? 437546
? 437550
? 437548
! 437548

result:

ok Correct position at 437548

Test #16:

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

input:

999996
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
11
10
11
10
10

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500005
? 750001
? 874999
? 937498
? 968747
? 984372
? 976560
? 972654
? 970701
? 969724
? 969236
? 968992
? 968870
? 968809
? 968778
? 968794
? 968786
? 968790
? 968788
! 968788

result:

ok Correct position at 968788

Test #17:

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

input:

999995
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
12
13
14
13
12
11
10
9
8
7
6
5
4
5
4
5
4
4

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500005
? 250010
? 125012
? 187511
? 218761
? 203136
? 195324
? 191418
? 189465
? 188488
? 188000
? 187756
? 187634
? 187573
? 187542
? 187558
? 187550
? 187554
? 187552
! 187552

result:

ok Correct position at 187552

Test #18:

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

input:

999994
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
11
10
11
10
10

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500004
? 749999
? 874997
? 937496
? 968745
? 984370
? 976558
? 972652
? 970699
? 969722
? 969234
? 968990
? 968868
? 968807
? 968776
? 968792
? 968784
? 968788
? 968786
! 968786

result:

ok Correct position at 968786

Test #19:

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

input:

999993
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
14
13
14
13
12
11
10
9
8
7
6
5
4
5
4
5
4
4

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500004
? 250009
? 375007
? 312508
? 343758
? 328133
? 320321
? 316415
? 314462
? 313485
? 312997
? 312753
? 312631
? 312570
? 312539
? 312555
? 312547
? 312551
? 312549
! 312549

result:

ok Correct position at 312549

Test #20:

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

input:

999992
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
11
10
11
10
10

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500003
? 749998
? 874995
? 937494
? 968743
? 984368
? 976556
? 972650
? 970697
? 969720
? 969232
? 968988
? 968866
? 968805
? 968774
? 968790
? 968782
? 968786
? 968784
! 968784

result:

ok Correct position at 968784

Test #21:

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

input:

999991
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
12
11
12
11
10
9
8
7
6
5
4
3
2
3
2
3
2
2

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500003
? 250009
? 125012
? 62513
? 93763
? 78138
? 70326
? 66420
? 64467
? 63490
? 63002
? 62758
? 62636
? 62575
? 62544
? 62560
? 62552
? 62556
? 62554
! 62554

result:

ok Correct position at 62554

Test #22:

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

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
1
2
3
4
5

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 500007
? 250011
? 125013
? 62514
? 31264
? 15639
? 7827
? 3921
? 1968
? 991
? 503
? 259
? 137
? 76
? 45
? 61
? 69
? 73
? 75
! 76

result:

wrong answer Wrong favorite light!