QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#32855#866. Display of SpringsFroggyguaRE 10ms3604kbC++171.4kb2022-05-25 08:46:232022-05-25 08:46:25

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-25 08:46:25]
  • 评测
  • 测评结果:RE
  • 用时:10ms
  • 内存:3604kb
  • [2022-05-25 08:46:23]
  • 提交

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;
	--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 if(Ask(t[u].p,id,R)){
			_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: 3ms
memory: 3544kb

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: 10ms
memory: 3604kb

input:

6
FIRST
EQUAL
FIRST
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
...

output:

? 1 0 50000
? 1 0 1
? 1 0 100000
? 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 ...

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...

result: