[原题链接](https://atcoder.jp/contests/abc261/tasks/abc261_c "原题链接") ### 题意 给定 n 个字符串,按以下规则输出: - 若这个字符串之前每出现过,则输出这个字符串。 - 若出现过则输出字符串和一个括号,括号里面是之前出现过多少次。 ### 思路 我们用一个 map 来存就好了 ### 代码 ```cpp #include using namespace std; map mp; int main () { int n; cin >> n; while (n --) { string s; cin >> s; cout << s; if (mp[s]) cout << '(' << mp[s] << ')'; cout << endl; mp[s] ++; } } ```