QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#832314 | #866. Display of Springs | cwfxlh | AC ✓ | 50ms | 6020kb | C++14 | 1.0kb | 2024-12-25 20:26:33 | 2024-12-25 20:26:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,mxv[500003],lf[100003],w,ans;
string s;
int Query(int a,int b,int W){
cout<<"? "<<a-1<<' '<<b-1<<' '<<W<<'\n';
fflush(stdout);
cin>>s;
if(s[0]=='F')return 1;
if(s[0]=='S')return 2;
return 0;
}
void build(int now,int l,int r){
if(l==r){lf[l]=now;return;}
build(now*2,l,((l+r)>>1));
build(now*2+1,((l+r)>>1)+1,r);
return;
}
void add(int now,int l,int r,int val){
if(mxv[now]&&Query(mxv[now],val,((l+r)/2))==2)swap(mxv[now],val);
if(!mxv[now]){swap(mxv[now],val);return;}
if(l==r)return;
if(Query(mxv[now],val,l)==2)add(now*2,l,((l+r)>>1),val);
else add(now*2+1,((l+r)>>1)+1,r,val);
return;
}
int main(){
cin>>n;
build(1,1,100000);
for(int i=1;i<=n;i++)add(1,1,100000,i);
cout<<"!\n";
fflush(stdout);
while(1){
cin>>s;
if(s[0]=='F')break;
cin>>w;
ans=0;
for(int i=lf[w];i;i/=2){
if(ans==0)ans=mxv[i];
else if(mxv[i]&&Query(ans,mxv[i],w)==2)ans=mxv[i];
}
cout<<"! "<<ans-1<<'\n';
fflush(stdout);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3960kb
input:
3 SECOND FIRST SECOND SECOND QUESTION 2 FIRST QUESTION 6 SECOND FINISH
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 2 1 1 ! ? 1 2 2 ! 1 ? 1 2 6 ! 2
result:
ok Correct answer
Test #2:
score: 0
Accepted
time: 1ms
memory: 5752kb
input:
6 SECOND EQUAL SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND QUESTION 1 FIRST FIRST FIRST FIRST QUESTION 2 EQUAL FIRST FIRST FIRST QUESTION 3 SECOND EQUAL FIRST FIRST QUESTION 4 SECOND SECOND EQUAL FIRST QU...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 2 1 1 ? 2 3 50000 ? 3 2 1 ? 1 2 25000 ? 2 1 1 ? 3 4 50000 ? 4 3 1 ? 2 3 25000 ? 3 2 1 ? 1 2 12500 ? 2 1 1 ? 4 5 50000 ? 5 4 1 ? 3 4 25000 ? 4 3 1 ? 2 3 12500 ? 3 2 1 ? 1 2 6250 ? 2 1 1 ! ? 1 2 1 ? 1 3 1 ? 1 4 1 ? 1 5 1 ! 1 ? 1 2 2 ? 1 3 2 ? 1 4 2 ? 1 5 2 ! 1 ? 1 2 3...
result:
ok Correct answer
Test #3:
score: 0
Accepted
time: 12ms
memory: 4016kb
input:
326 FIRST FIRST FIRST SECOND SECOND SECOND SECOND SECOND FIRST SECOND FIRST SECOND SECOND FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST FIRST FIRST SECOND FIRST SECO...
output:
? 0 1 50000 ? 0 1 1 ? 0 2 50000 ? 0 2 1 ? 0 3 50000 ? 3 0 1 ? 2 0 25000 ? 0 2 1 ? 3 4 50000 ? 3 4 1 ? 0 4 25000 ? 0 4 1 ? 2 4 12500 ? 4 2 1 ? 3 5 50000 ? 3 5 1 ? 1 5 75000 ? 1 5 50001 ? 3 6 50000 ? 3 6 1 ? 0 6 25000 ? 0 6 1 ? 3 7 50000 ? 3 7 1 ? 0 7 25000 ? 0 7 1 ? 6 7 37500 ? 6 7 25001 ? 3 8 50000 ...
result:
ok Correct answer
Test #4:
score: 0
Accepted
time: 6ms
memory: 3992kb
input:
19 SECOND FIRST FIRST FIRST SECOND FIRST FIRST FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND FIRS...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 1 2 1 ? 0 2 75000 ? 2 0 50001 ? 1 3 50000 ? 1 3 1 ? 2 3 75000 ? 3 2 50001 ? 0 2 87500 ? 2 0 75001 ? 1 4 50000 ? 1 4 1 ? 3 4 75000 ? 3 4 50001 ? 2 4 87500 ? 2 4 75001 ? 0 4 93750 ? 0 4 87501 ? 1 5 50000 ? 1 5 1 ? 3 5 75000 ? 3 5 50001 ? 2 5 87500 ? 2 5 75001 ? 0 5 93...
result:
ok Correct answer
Test #5:
score: 0
Accepted
time: 26ms
memory: 4120kb
input:
500 SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 2 1 1 ? 0 1 75000 ? 1 0 50001 ? 2 3 50000 ? 3 2 1 ? 1 2 75000 ? 2 1 50001 ? 0 1 87500 ? 1 0 75001 ? 3 4 50000 ? 3 4 1 ? 2 4 75000 ? 2 4 50001 ? 1 4 87500 ? 1 4 75001 ? 0 4 93750 ? 4 0 87501 ? 3 5 50000 ? 3 5 1 ? 2 5 75000 ? 2 5 50001 ? 1 5 87500 ? 1 5 75001 ? 4 5 93...
result:
ok Correct answer
Test #6:
score: 0
Accepted
time: 14ms
memory: 4128kb
input:
500 EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQUAL EQ...
output:
? 0 1 50000 ? 0 1 1 ? 0 2 50000 ? 0 2 1 ? 1 2 75000 ? 1 2 50001 ? 0 3 50000 ? 0 3 1 ? 1 3 75000 ? 1 3 50001 ? 2 3 87500 ? 2 3 75001 ? 0 4 50000 ? 0 4 1 ? 1 4 75000 ? 1 4 50001 ? 2 4 87500 ? 2 4 75001 ? 3 4 93750 ? 3 4 87501 ? 0 5 50000 ? 0 5 1 ? 1 5 75000 ? 1 5 50001 ? 2 5 87500 ? 2 5 75001 ? 3 5 93...
result:
ok Correct answer
Test #7:
score: 0
Accepted
time: 50ms
memory: 5848kb
input:
500 SECOND FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRS...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 1 2 1 ? 0 2 75000 ? 0 2 50001 ? 1 3 50000 ? 3 1 1 ? 0 1 75000 ? 1 0 50001 ? 2 0 87500 ? 0 2 75001 ? 3 4 50000 ? 3 4 1 ? 1 4 75000 ? 1 4 50001 ? 0 4 87500 ? 0 4 75001 ? 2 4 93750 ? 4 2 87501 ? 3 5 50000 ? 3 5 1 ? 1 5 75000 ? 1 5 50001 ? 0 5 87500 ? 0 5 75001 ? 4 5 93...
result:
ok Correct answer
Test #8:
score: 0
Accepted
time: 26ms
memory: 4076kb
input:
500 FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND FIRST FIRST FIRST FIRST FIRST FIRST FIRST ...
output:
? 0 1 50000 ? 0 1 1 ? 0 2 50000 ? 0 2 1 ? 1 2 75000 ? 2 1 50001 ? 0 3 50000 ? 0 3 1 ? 2 3 75000 ? 2 3 50001 ? 1 3 87500 ? 3 1 75001 ? 0 4 50000 ? 0 4 1 ? 2 4 75000 ? 2 4 50001 ? 3 4 87500 ? 3 4 75001 ? 1 4 93750 ? 4 1 87501 ? 0 5 50000 ? 0 5 1 ? 2 5 75000 ? 2 5 50001 ? 3 5 87500 ? 3 5 75001 ? 4 5 93...
result:
ok Correct answer
Test #9:
score: 0
Accepted
time: 3ms
memory: 4028kb
input:
2 SECOND SECOND QUESTION 64500 QUESTION 22602 SECOND QUESTION 37446 SECOND QUESTION 97972 QUESTION 78630 QUESTION 75591 QUESTION 63328 QUESTION 64746 QUESTION 94532 QUESTION 51275 QUESTION 12189 SECOND QUESTION 64341 QUESTION 85825 QUESTION 63713 QUESTION 36778 SECOND QUESTION 27116 SECOND QUESTION ...
output:
? 0 1 50000 ? 1 0 1 ! ! 1 ? 0 1 22602 ! 1 ? 0 1 37446 ! 1 ! 1 ! 1 ! 1 ! 1 ! 1 ! 1 ! 1 ? 0 1 12189 ! 1 ! 1 ! 1 ! 1 ? 0 1 36778 ! 1 ? 0 1 27116 ! 1 ? 0 1 18630 ! 1 ! 1 ? 0 1 28074 ! 1 ! 1 ! 1 ? 0 1 39195 ! 1 ! 1 ? 0 1 1182 ! 1 ! 1 ! 1 ! 1 ? 0 1 7017 ! 1 ? 0 1 13589 ! 1 ! 1 ! 1 ? 0 1 48324 ! 1 ! 1 ! 1 ...
result:
ok Correct answer
Test #10:
score: 0
Accepted
time: 3ms
memory: 4088kb
input:
2 SECOND SECOND QUESTION 54311 QUESTION 8466 FIRST QUESTION 82055 QUESTION 65419 QUESTION 5271 FIRST QUESTION 4799 FIRST QUESTION 21521 SECOND QUESTION 66767 QUESTION 24897 SECOND QUESTION 69127 QUESTION 84527 QUESTION 23303 SECOND QUESTION 88924 QUESTION 56421 QUESTION 88108 QUESTION 74033 QUESTION...
output:
? 0 1 50000 ? 1 0 1 ! ! 1 ? 0 1 8466 ! 0 ! 1 ! 1 ? 0 1 5271 ! 0 ? 0 1 4799 ! 0 ? 0 1 21521 ! 1 ! 1 ? 0 1 24897 ! 1 ! 1 ! 1 ? 0 1 23303 ! 1 ! 1 ! 1 ! 1 ! 1 ? 0 1 25348 ! 1 ? 0 1 10105 ! 0 ! 1 ? 0 1 33359 ! 1 ? 0 1 49782 ! 1 ? 0 1 20392 ! 1 ! 1 ! 1 ? 0 1 4246 ! 0 ! 1 ? 0 1 8620 ! 0 ? 0 1 30435 ! 1 ? 0...
result:
ok Correct answer
Test #11:
score: 0
Accepted
time: 5ms
memory: 4124kb
input:
500 FIRST SECOND SECOND SECOND SECOND SECOND FIRST SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND FIRST SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECO...
output:
? 0 1 50000 ? 0 1 1 ? 0 2 50000 ? 2 0 1 ? 1 0 25000 ? 0 1 1 ? 2 3 50000 ? 2 3 1 ? 0 3 25000 ? 3 0 1 ? 1 0 12500 ? 0 1 1 ? 2 4 50000 ? 4 2 1 ? 3 2 25000 ? 2 3 1 ? 0 3 12500 ? 3 0 1 ? 1 0 6250 ? 0 1 1 ? 4 5 50000 ? 4 5 1 ? 2 5 25000 ? 5 2 1 ? 3 2 12500 ? 2 3 1 ? 0 3 6250 ? 3 0 1 ? 1 0 3125 ? 0 1 1 ? 4...
result:
ok Correct answer
Test #12:
score: 0
Accepted
time: 4ms
memory: 4064kb
input:
500 SECOND SECOND SECOND SECOND SECOND SECOND FIRST SECOND SECOND SECOND SECOND SECOND FIRST SECOND FIRST SECOND SECOND FIRST FIRST SECOND FIRST SECOND FIRST FIRST SECOND FIRST FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND FIRST SECOND FIRST FIRST SECOND FIRST ...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 2 1 1 ? 0 1 25000 ? 1 0 1 ? 2 3 50000 ? 2 3 1 ? 1 3 25000 ? 3 1 1 ? 0 1 12500 ? 1 0 1 ? 2 4 50000 ? 2 4 1 ? 3 4 25000 ? 3 4 1 ? 1 4 12500 ? 4 1 1 ? 2 5 50000 ? 2 5 1 ? 3 5 25000 ? 3 5 1 ? 4 5 12500 ? 4 5 1 ? 1 5 18750 ? 5 1 12501 ? 2 6 50000 ? 2 6 1 ? 3 6 25000 ? 3 ...
result:
ok Correct answer
Test #13:
score: 0
Accepted
time: 16ms
memory: 4008kb
input:
500 SECOND SECOND SECOND SECOND SECOND SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND SECO...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 2 1 1 ? 0 1 25000 ? 1 0 1 ? 2 3 50000 ? 2 3 1 ? 1 3 25000 ? 1 3 1 ? 0 3 12500 ? 3 0 1 ? 2 4 50000 ? 2 4 1 ? 1 4 25000 ? 1 4 1 ? 3 4 12500 ? 3 4 1 ? 0 4 6250 ? 4 0 1 ? 2 5 50000 ? 2 5 1 ? 1 5 25000 ? 1 5 1 ? 3 5 12500 ? 3 5 1 ? 4 5 6250 ? 4 5 1 ? 0 5 3125 ? 0 5 1 ? 2...
result:
ok Correct answer
Test #14:
score: 0
Accepted
time: 20ms
memory: 3964kb
input:
500 SECOND SECOND FIRST SECOND SECOND SECOND FIRST FIRST FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND FIRST SECOND FIRST FIRST FIRST SECOND FIRST SECOND FIRST FIRST FIRST SECOND SECOND SECOND FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND FIRST FIRST SECOND FIR...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 1 2 1 ? 0 2 25000 ? 2 0 1 ? 1 3 50000 ? 1 3 1 ? 1 4 50000 ? 1 4 1 ? 2 4 25000 ? 2 4 1 ? 0 4 12500 ? 4 0 1 ? 1 5 50000 ? 1 5 1 ? 2 5 25000 ? 2 5 1 ? 4 5 12500 ? 4 5 1 ? 1 6 50000 ? 1 6 1 ? 2 6 25000 ? 2 6 1 ? 4 6 12500 ? 4 6 1 ? 5 6 18750 ? 5 6 12501 ? 1 7 50000 ? 7 ...
result:
ok Correct answer
Test #15:
score: 0
Accepted
time: 25ms
memory: 3964kb
input:
500 SECOND SECOND SECOND SECOND SECOND SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND FIRST SECOND SECOND SECOND SECOND SECOND FIRST SECOND FIRST SECOND SECOND SECOND SECOND SECOND FIRST FIRST FIRST SECOND FIRST SECOND FIRST SECOND FIRST FIRST FIRST SECOND FIRST SECOND SECOND SECOND FIR...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 2 1 1 ? 0 1 25000 ? 1 0 1 ? 2 3 50000 ? 2 3 1 ? 1 3 25000 ? 1 3 1 ? 0 3 12500 ? 3 0 1 ? 2 4 50000 ? 2 4 1 ? 1 4 25000 ? 1 4 1 ? 3 4 12500 ? 4 3 1 ? 0 3 6250 ? 3 0 1 ? 2 5 50000 ? 2 5 1 ? 1 5 25000 ? 1 5 1 ? 4 5 12500 ? 5 4 1 ? 3 4 6250 ? 4 3 1 ? 0 3 3125 ? 0 3 1 ? 2...
result:
ok Correct answer
Test #16:
score: 0
Accepted
time: 8ms
memory: 6020kb
input:
500 SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND FIRST FIRST SECOND SECOND SECOND SECOND SECOND FIRST FIRST SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST...
output:
? 0 1 50000 ? 1 0 1 ? 1 2 50000 ? 1 2 1 ? 0 2 25000 ? 0 2 1 ? 1 3 50000 ? 1 3 1 ? 0 3 25000 ? 0 3 1 ? 2 3 12500 ? 3 2 1 ? 1 4 50000 ? 1 4 1 ? 0 4 25000 ? 0 4 1 ? 3 4 12500 ? 3 4 1 ? 2 4 6250 ? 4 2 1 ? 1 5 50000 ? 1 5 1 ? 0 5 25000 ? 0 5 1 ? 3 5 12500 ? 3 5 1 ? 4 5 6250 ? 5 4 1 ? 1 6 50000 ? 1 6 1 ? ...
result:
ok Correct answer