F - Set of Strings
题目大意:
拆分成n个以不同首字母开头的字符串
#include<iostream> #include<vector> #include <string> using namespace std; bool vis[35]={0}; int main() { vector<int >q; int n,sum=0; string s; cin>>n>>s; for(int i=0;i<s.size();i++) if(!vis[s[i]-'a']) vis[s[i]-'a']=1,sum++,q.push_back(i); if(sum<n) cout<<"NO"<<endl; else { cout<<"YES"<<endl; for(int j=0;j<n;j++) { int k; if(j!=n-1) { for( k=q[j];k<q[j+1];k++) cout<<s[k]; cout<<endl; } else { for( k=q[j];k<s.size();k++) cout<<s[k]; cout<<endl; } } } return 0; }