辩论队团建去了,结果错过了register的时间,很尴尬的就只能事后补题了
B题的话sort也完全可以,毕竟 n<10可以乱玩,然后的话我想用用map,所以就是快乐的暴力了.
#include <cstdio> #include <string> #include <iostream> #include <map> using namespace std; map <string, int> M; string s[11]; inline void change(int k) { M[s[k]]--; for (int i = 0; i <= 9; i++) { s[k][3] = i + '0'; if (M[s[k]] == 0) { M[s[k]] = 1; break; } } } int main() { int n, t; scanf("%d", &t); while (t--) { int n; M.clear(); scanf("%d", &n); for (int i = 0; i < n; i++) { cin >> s[i]; M[s[i]]++; } int ans = 0; for (int i = 0; i < n; i++) { if (M[s[i]] > 1) change(i),ans++; } printf("%d ", ans); for (int i = 0; i < n; i++) cout << s[i] << endl; } return 0; }