谴责公主 - CodeForces 1536B - 虚拟法官 (csgrandeur.cn)
(29条消息) codeforces 1536B. Prinzessin der Verurteilung(1200)_Theiar的博客-CSDN博客
题意:求字典序最小的且不是给定字符串中连续字符组成的子串的字符串
暴力求一个字符串的全部连续字符子串
set<string> st;
for(int i=0;i<s.size();i++)
{
for(int j=1;i+j<=s.size();j++)
{
string t=s.substr(i,j);
st.insert(t);
}
}
#include<bits/stdc++.h>
#define x first
#define gcfx main
#define y second
#define mak make_pair
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define debug(a) cout<<a<<'\n'
#define endl '\n'
#define umap unordered_map
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
const int N=2e5+10,M=1,inf=0x3f3f3f3f,mod=1e9+7;
int t,n;
queue<string> q;
string res,s;
set<string> st;
void bfs()
{
string x;q.push(x);
while(q.size())
{
string temp=q.front();q.pop();
if(st.find(temp)==st.end()&&temp.size()!=0)
{
res=temp;
return;
}
for(int i=0;i<26;i++)
{
string t=temp+char('a'+i);
q.push(t);
}
}
}
void solve()
{
cin>>n>>s;
res.clear();
st.clear();
for(int i=0;i<s.size();i++)
{
for(int j=1;i+j<=s.size();j++)
{
string t=s.substr(i,j);
st.insert(t);
}
}
bfs();
cout<<res<<endl;
while(q.size()) q.pop();
}
int gcfx()
{
IOS;
cin>>t;
while(t--) solve();
return 0;
}