题意描述
给你一个字符串评判机制,每次询问给个字符串,问是否符合要求。
简要分析
不难发现 FBFFBFFB 是循环节,只需判断 s s s 是否在有上述循环节组成的字符串中即可。
代码实现
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 7;
const ll INF = 1e9 + 7, MOD = 998244353;
inline ll read() {
char cCc;
ll xXx = 0, wWw = 1;
while (cCc < '0' || cCc > '9')
(cCc == '-') && (wWw = -wWw), cCc = getchar();
while (cCc >= '0' && cCc <= '9')
xXx = (xXx << 1) + (xXx << 3) + (cCc ^ '0'), cCc = getchar();
xXx *= wWw;
return xXx;
}
string t = "FBFFBFFBFBFFBFFBFBFFBFFBFBFFBFFB";
void solve() {
ll n;
string s;
cin >> n >> s;
if (t.find(s) != string::npos) cout << "Yes" << '\n';
else cout << "No" << '\n';
}
signed main() {
// freopen("code.in","r",stdin);
// freopen("code.out","w",stdout);
ll T = read();
while (T--) solve();
return 0;
}