题解:CF2280B Secret String Patterns
题目传送门
题目描述
交互题。给定一个隐藏长为
解法描述
简单题。
显然当一个序列不满足条件时所有
那我们就可以先问整个区间里所有
那这道题就用两次询问搞定了。
需要注意的细节就是如果第一次查询时得到的
以及在大多数情况下 CodeForces 对于 YES 和 NO 都是有 Special Judge 的,但是这道题没有,所以要注意一下。
AC Code
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#define int long long
//#define endl '\n'
using namespace std;
int T,N;
signed main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
cin>>T;
while(T--)
{
cin>>N;int x,y;
cout<<"? 1 "<<N<<endl;cin>>x;
if(x==N||!x)
{
cout<<"! NO"<<endl;continue;
}
cout<<"? 1 "<<x<<endl;cin>>y;
if(x==y)
{
cout<<"! NO"<<endl;continue;
}
cout<<"! YES"<<endl;
}
return 0;
}
完结撒花!