For two strings $A$ and $B$, let $A+B$ denote the concatenation of $A$ and $B$ in this order. You are given $N$ strings $S_1,\ldots,S_N$. Modify and print them as follows, in the order $i=1, \ldots, N$:Problem Statement
(
$+X+$ )
, treating $X$ as a string. Constraints
Input
Input is given from Standard Input in the following format:
$N$ $S_1$ $S_2$ $\vdots$ $S_N$
Output
Print $N$ lines as specified in the Problem Statement.
Sample Input 1
5 newfile newfile newfolder newfile newfolder
Sample Output 1
newfile newfile(1) newfolder newfile(2) newfolder(1)
Sample Input 2
11 a a a a a a a a a a a
Sample Output 2
a a(1) a(2) a(3) a(4) a(5) a(6) a(7) a(8) a(9) a(10)
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
string s[N];
char t[15];
int n;
map<string,int>g;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%s",t);
s[i]=t;
printf("%s",t);
if(g[s[i]])
printf("(%d)",g[s[i]]);
putchar('\n');
g[s[i]]++;
}
}
标签:NewFolder,int,Sample,newfolder,Input,ldots,newfile
From: https://www.cnblogs.com/mekoszc/p/16656121.html