Skip to content

Commit

Permalink
1924A
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-yidie committed Oct 30, 2024
1 parent e664928 commit 9800a69
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions CF1924A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include<bits/stdc++.h>
using namespace std;
typedef long long LL ;
typedef pair<int,int> pii;
const int N = 2e5+50 , mod = 1e9+7;

LL n , m , q , k ,ans , tar , cnt ;
char c;
bool pos[26];
string tmp;
void AC() {
cin >> n >> m >> k ; tar = cnt = 0 ; tmp = "";
memset(pos , 0 , sizeof (pos));
while (k--) {
cin >> c ;
cnt += ( !pos[c-'a'] && c - 'a' < m ) ;
pos[ c-'a'] = 1;
if (cnt == m) {
cnt = 0 ; tar++; tmp += c;
memset(pos , 0 , sizeof (pos));
}
}
if (tar >= n) {
cout << "YES\n";
} else {
while (tar < n - 1) {
tmp += 'a' ; tar++;
}
for (int i = 0 ; ; i++) {
if (!pos[i]) {
tmp += (char)(i+'a');
break;
}
}
cout << "NO\n" << tmp << '\n';
}
}

int main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int T = 1 ;
cin >> T ;
while (T--) {
AC();
}
return 0;
}
Binary file added output/CF1924A.exe
Binary file not shown.

0 comments on commit 9800a69

Please sign in to comment.