其他分享
首页 > 其他分享> > 1536B - Prinzessin der Verurteilung

1536B - Prinzessin der Verurteilung

作者:互联网

BFS:

暴力枚举所有情况即可

#include <iostream>
#include <queue>
using namespace std;
int n;
string s;
string bfs () {
	queue <string> q;
	for (int i = 0;i < 26;i++) {
		string t;
		t += i+'a';
		q.push (t);
	}
	while (!q.empty ()) {
		string t = q.front ();
		q.pop ();
		if (s.find (t) == -1) return t;
		for (int i = 0;i < 26;i++) q.push (t+char(i+'a'));
	}
}
int main () {
	int T;
	cin >> T;
	while (T--) {
		cin >> n >> s;
		cout << bfs () << endl;
	}
	return 0;
}

标签:26,string,int,der,++,while,1536B,include,Verurteilung
来源: https://www.cnblogs.com/incra/p/16389957.html