QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417518 | #6394. Turn on the Light | LCJ | WA | 1ms | 3624kb | C++14 | 649b | 2024-05-22 19:29:07 | 2024-05-22 19:29:07 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int n,m,k,q,ans;
int ask(int x){
cout<<"? "<<x<<endl;
//cout.flush();
int res;
cin>>res;
return res;
}
void solve(){
cin>>n;
k=0;
int l=1,r=n;
for(int i=1;i<=10;i++){
int kk=ask(i);
if(k==kk){
cout<<"! "<<i<<endl;
return;
}
k=kk;
}
ans=10;
while(l<=r){
int mid=(l+r)/2;
ans=ask(mid);
if(ans==k){
cout<<"! "<<mid<<endl;
return;
}
if(k<ans){
k=ans;
l=mid+1;
}
else{
k=ans;
r=mid-1;
}
}
}
signed main(){
int T=1;
//cin>>T;
while(T--){
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3612kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 1ms
memory: 3584kb
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: 0ms
memory: 3512kb
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: 0ms
memory: 3472kb
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: 0ms
memory: 3472kb
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: 3492kb
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: 0ms
memory: 3616kb
input:
5 1 2 3 3
output:
? 1 ? 2 ? 3 ? 4 ! 4
result:
ok Correct position at 4
Test #8:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
4 1 2 3 3
output:
? 1 ? 2 ? 3 ? 4 ! 4
result:
ok Correct position at 4
Test #9:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
3 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #10:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
2 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #11:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
1 0
output:
? 1 ! 1
result:
ok Correct position at 1
Test #12:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 18 19 20 21 22 21 22 23 24 23 23
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500000 ? 750000 ? 875000 ? 937500 ? 968750 ? 984375 ? 992188 ? 996094 ? 998047 ? 999024 ? 998535 ? 998779 ? 998901 ? 998962 ? 998993 ? 998977 ? 998985 ? 998989 ? 998991 ? 998990 ! 998990
result:
ok Correct position at 998990
Test #13:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
999999 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500000 ? 750000 ? 625000 ? 687500 ? 718750 ? 703125 ? 710937 ? 714843 ? 716796 ? 717773 ? 717284 ? 717528 ? 717650 ? 717711 ? 717742 ? 717726 ? 717734 ? 717738 ? 717740 ? 717739 ! 717739
result:
ok Correct position at 717739
Test #14:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
999998 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 499999 ? 749999 ? 624999 ? 687499 ? 718749 ? 703124 ? 710936 ? 714842 ? 716795 ? 717772 ? 717283 ? 717527 ? 717649 ? 717710 ? 717741 ? 717725 ? 717733 ? 717737 ? 717739 ? 717738 ! 717738
result:
ok Correct position at 717738
Test #15:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
999997 1 2 3 4 5 6 7 8 9 10 11 12 13 14 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 499999 ? 749998 ? 874998 ? 937498 ? 968748 ? 953123 ? 960935 ? 964841 ? 966794 ? 967771 ? 967282 ? 967526 ? 967648 ? 967709 ? 967740 ? 967724 ? 967732 ? 967736 ? 967738 ? 967737 ! 967737
result:
ok Correct position at 967737
Test #16:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
999996 1 2 3 4 5 6 7 8 9 10 11 12 13 14 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 499998 ? 749997 ? 874997 ? 937497 ? 968747 ? 953122 ? 960934 ? 964840 ? 966793 ? 967770 ? 967281 ? 967525 ? 967647 ? 967708 ? 967739 ? 967723 ? 967731 ? 967735 ? 967737 ? 967736 ! 967736
result:
ok Correct position at 967736
Test #17:
score: 0
Accepted
time: 1ms
memory: 3484kb
input:
999995 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 499998 ? 749997 ? 624997 ? 687497 ? 718747 ? 703122 ? 710934 ? 714840 ? 716793 ? 717770 ? 717281 ? 717525 ? 717647 ? 717708 ? 717739 ? 717723 ? 717731 ? 717735 ? 717737 ? 717736 ! 717736
result:
ok Correct position at 717736
Test #18:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
999994 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 499997 ? 749996 ? 624996 ? 687496 ? 718746 ? 703121 ? 710933 ? 714839 ? 716792 ? 717769 ? 717280 ? 717524 ? 717646 ? 717707 ? 717738 ? 717722 ? 717730 ? 717734 ? 717736 ? 717735 ! 717735
result:
ok Correct position at 717735
Test #19:
score: 0
Accepted
time: 1ms
memory: 3516kb
input:
999993 1 2 3 4 5 6 7 8 9 10 11 12 13 14 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 499997 ? 749995 ? 874994 ? 937494 ? 968744 ? 953119 ? 960931 ? 964837 ? 966790 ? 967767 ? 967278 ? 967522 ? 967644 ? 967705 ? 967736 ? 967720 ? 967728 ? 967732 ? 967734 ? 967733 ! 967733
result:
ok Correct position at 967733
Test #20:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
999992 1 2 3 4 5 6 7 8 9 10 11 12 13 14 13 14 15 16 17 16 17 18 19 20 19 20 21 22 21 21
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 499996 ? 749994 ? 874993 ? 937493 ? 968743 ? 953118 ? 960930 ? 964836 ? 966789 ? 967766 ? 967277 ? 967521 ? 967643 ? 967704 ? 967735 ? 967719 ? 967727 ? 967731 ? 967733 ? 967732 ! 967732
result:
ok Correct position at 967732
Test #21:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
999991 1 2 3 4 5 6 7 8 9 10 11 10 11 12 11 12 13 14 15 14 15 16 17 18 17 18 19 20 19 19
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 499996 ? 749994 ? 624995 ? 687494 ? 718744 ? 703119 ? 710931 ? 714837 ? 716790 ? 717767 ? 717278 ? 717522 ? 717644 ? 717705 ? 717736 ? 717720 ? 717728 ? 717732 ? 717734 ? 717733 ! 717733
result:
ok Correct position at 717733
Test #22:
score: -100
Wrong Answer
time: 0ms
memory: 3472kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 500000 ? 250000 ? 125000 ? 62500 ? 31250 ? 15625 ? 7812 ? 3906 ? 1953 ? 976 ? 488 ? 732 ? 854 ? 915 ? 945 ? 960 ? 968 ? 972 ? 974 ? 975
result:
wrong answer format Unexpected end of file - token expected