Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- string s[100];
- int m,n;
- bool strcmp(string a, string b){
- for(int i=0;i<b.length();i++){
- string tmp="";
- for(int j=0;j<a.length();j++){
- tmp.push_back(b[i+j]);
- }
- if(tmp==a){
- return false;
- }
- }
- return true;
- }
- void cheak(int len,int m, string st){
- if(len==m){
- bool flag=true;
- for(int i=0;i<n;i++){
- bool f = strcmp(s[i],st);
- if(f==false){
- flag=false;
- break;
- }
- }
- if(flag==false) return;
- else{
- cout<<st<<endl;
- return;
- }
- }
- for(char i='a';i<='z';i++){
- string tmp=st;
- tmp=tmp+i;
- cheak(len+1,m,tmp);
- }
- }
- int main()
- {
- cin>>m>>n;
- for(int i=0;i<n;i++){
- cin>>s[i];
- }
- cheak(0,m,"");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement