Codeforces-SolutionsA/Codes/1811 A - Insert Digit/1811A.cpp

35 lines
520 B
C++
Raw Normal View History

2023-07-13 02:28:41 +08:00
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n;
char c;
cin >> n >> c;
string s;
cin >> s;
for (int i = 0; i < s.size(); ++i)
{
if (c > s[i])
{
s.insert(i, 1, c);
cout << s << endl;
return;
}
}
s=s+c;
cout<<s<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
cin >> TC;
cin.ignore();
while (TC--)
solve();
}