QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#32857 | #866. Display of Springs | Froggygua | RE | 4ms | 3656kb | C++17 | 1.4kb | 2022-05-25 08:48:56 | 2022-05-25 08:48:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 100010
typedef long long ll;
int n;
int Ask(int a,int b,int k){
if(!b)return -1;
if(!a)return 1;
--a,--b;
cout<<"? "<<a<<' '<<b<<' '<<k<<endl;
string s;
cin>>s;
if(s=="FIRST")return -1;
if(s=="SECOND")return 1;
return 0;
}
void Report(int x){
--x;
cout<<"! "<<x<<endl;
}
class Segment_Tree{
int Len;
struct node{
int p;
}t[N<<2];
#define ls u<<1
#define rs u<<1|1
void _ins(int u,int L,int R,int id){
if(!id)return;
if(L==R){
if(!t[u].p||Ask(id,t[u].p,L)==-1){
t[u].p=id;
return;
}
}
int mid=(L+R)>>1;
if(Ask(id,t[u].p,mid)==-1){
swap(id,t[u].p);
}
if(Ask(t[u].p,id,L)){
_ins(ls,L,mid,id);
}
else{
_ins(rs,mid+1,R,id);
}
}
int _query(int u,int L,int R,int pos){
if(L==R){
return t[u].p;
}
int mid=(L+R)>>1;
int ans=t[u].p;
int x=pos<=mid?_query(ls,L,mid,pos):_query(rs,mid+1,R,pos);
if(Ask(ans,x,pos)==1)ans=x;
return ans;
}
public:
void init(int n,int _len){
Len=_len;
for(int i=1;i<=n;++i){
_ins(1,1,Len,i);
}
}
int Query(int p){
return _query(1,1,Len,p);
}
}T;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
T.init(n,100000);
cout<<"!"<<endl;
while(true){
string opt;
cin>>opt;
if(opt=="FINISH")break;
int x;
cin>>x;
Report(T.Query(x));
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 3656kb
input:
3 FIRST FIRST FIRST SECOND FIRST FIRST QUESTION 2 FIRST SECOND QUESTION 6 FIRST FIRST FINISH
output:
? 1 0 50000 ? 1 0 1 ? 2 1 50000 ? 2 1 1 ? 1 0 25000 ? 1 0 1 ! ? 1 0 2 ? 2 1 2 ! 1 ? 1 0 6 ? 2 1 6 ! 2
result:
ok Correct answer
Test #2:
score: 0
Accepted
time: 2ms
memory: 3656kb
input:
6 FIRST EQUAL FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND QUESTION 1 SECOND SECOND SECOND SECOND QUESTION 2 EQUAL SECOND SECOND SECOND QUESTION 3 FIRST EQUAL SECOND SECOND QUESTION 4 FIRST FIRST EQUAL SECOND QUESTI...
output:
? 1 0 50000 ? 1 0 1 ? 2 1 50000 ? 2 1 1 ? 3 2 50000 ? 3 2 1 ? 2 1 25000 ? 2 1 1 ? 4 3 50000 ? 4 3 1 ? 3 2 25000 ? 3 2 1 ? 2 1 12500 ? 2 1 1 ? 5 4 50000 ? 5 4 1 ? 4 3 25000 ? 4 3 1 ? 3 2 12500 ? 3 2 1 ? 2 1 6250 ? 2 1 1 ! ? 2 1 1 ? 3 1 1 ? 4 1 1 ? 5 1 1 ! 1 ? 2 1 2 ? 3 2 2 ? 4 2 2 ? 5 2 2 ! 2 ? 2 1 3...
result:
ok Correct answer
Test #3:
score: -100
Runtime Error
input:
326 SECOND FIRST SECOND SECOND SECOND SECOND FIRST SECOND FIRST FIRST FIRST SECOND SECOND SECOND SECOND SECOND FIRST FIRST FIRST SECOND SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND FIRST SECOND SECOND SECOND FIRST SECOND FIRST FIRST FIRST FIRST SECOND FIRST FIRST SECOND SECOND SECOND F...
output:
? 1 0 50000 ? 0 1 1 ? 2 0 50000 ? 0 2 1 ? 2 1 25000 ? 1 2 1 ? 3 0 50000 ? 3 0 1 ? 0 1 25000 ? 0 1 1 ? 1 2 12500 ? 1 2 1 ? 4 3 50000 ? 3 4 1 ? 4 0 25000 ? 0 4 1 ? 4 1 12500 ? 4 1 1 ? 1 2 6250 ? 1 2 1 ? 5 3 50000 ? 3 5 1 ? 5 0 25000 ? 0 5 1 ? 5 4 12500 ? 4 5 1 ? 5 1 6250 ? 1 5 1 ? 5 2 3125 ? 2 5 1 ? 6...