Topic Portal
1 /*2 Test Instructions: A string is divided into K-segments, each beginning with a different letter3 water problem: Record the number of occurrences of each letter, each split the number of initial letters down to 0, the last paragraph directly all output4 */5#include <cstdio>6#include <iostream>7#include <cstring>8#include <string>9#include <algorithm>Ten using namespacestd; One A Const intMAXN = 1e2 +Ten; - Const intINF =0x3f3f3f3f; - CharS[MAXN]; the intnum[ -]; - - intMainvoid)//codeforces Round #302 (Div. 2) A Set of Strings - { + //freopen ("a.in", "R", stdin); - + intK; A while(SCANF ("%d", &k) = =1) at { -scanf ("%s", &s); - if(k = =1) {puts ("YES"); printf ("%s\n", s);Continue;} - -memset (NUM,0,sizeof(num)); - intLen =strlen (s); in for(intI=0; i<len; ++i) num[s[i]-'a']++; - intt =0; to for(intI=0; i< -; ++i)if(Num[i]) + +T; + if(T < k) {Puts ("NO");Continue;} - thePuts ("YES"); *printf ("%c", s[0]); num[s[0]-'a'] =0; $ intp =0;inti;Panax Notoginseng for(i=1; i<len; ++i) - { the if(!num[s[i]-'a']) {printf ("%c", S[i]);} + Else A { thenum[s[i]-'a'] =0; Puts (""); +printf ("%c", S[i]); ++p; - } $ if(p = = k-1) Break; $ } - - for(intj=i+1; j<len; ++J) printf ("%c", S[j]); thePuts (""); - }Wuyi the return 0; -}
Water problem codeforces Round #302 (Div. 2) A Set of Strings