Problem Statement

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$:

  • if none of $S_1,\ldots,S_{i-1}$ is equal to $S_i$, print $S_i$;
  • if $X$ $(X>0)$ of $S_1,\ldots,S_{i-1}$ are equal to $S_i$, print $S_i+$ ( $+X+$ ), treating $X$ as a string.

Constraints

  • $1 \leq N \leq 2\times 10^5$
  • $S_i$ is a string of length between $1$ and $10$ (inclusive) consisting of lowercase English letters.

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)

拿个map对字符串进行统计即可。

#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]]++;
}
}

[ABC261C] NewFolder(1)的更多相关文章

  1. 「译」JUnit 5 系列:扩展模型(Extension Model)

    原文地址:http://blog.codefx.org/design/architecture/junit-5-extension-model/ 原文日期:11, Apr, 2016 译文首发:Lin ...

  2. Linux用户管理(centos)

    useradd testuser; 添加用户 testuser为用户名 passwd testuser; 修改用户密码 提示两次输入密码   赋予root权限 修改 /etc/sudoers 文件,找 ...

  3. Java 程序员必须掌握的 Linux 命令(转:导师Jencks)

    1.查找文件 find / -name filename.txt根据名称查找/目录下的filename.txt文件. find . -name "*.xml"递归查找所有的xml文 ...

  4. vs2008所有DTE.ExecuteCommand命令

    下面列表中为我当前机器上visual studio 2008所有DTE.ExecuteCommand命令的内容: 其中:Build.开头对应“编译”菜单下命令(如:Build.RebuildSolut ...

  5. 修改后的CopyFile类

    这是修改后的CopyFile类,前面那个类有局限性,它不能复制大文件 这是我第一次写成一个能够实际应用的类,感谢博主们的无私奉献,感谢SeayXu老师的提点 但是这个类也并不是完美无缺,它复制文件没有 ...

  6. [已解决] git 重命名文件夹

    git mv oldfolder newfolder 原文地址:http://www.cnblogs.com/gifisan/p/5980608.html

  7. C#调用RAR压缩与解压

    public void RARsave(string rarPatch, string rarFiles,string  patch,string rarName)        {          ...

  8. TFS二次开发系列:六、TFS的版本控制

    在TFS中对于版本控制是在WorkSpace工作区来控制的. 首先我们先整理WorkSpace的一些基本使用方法. CheckIn:迁入挂起的操作 CreateMapping:创建一个本地映射地址 D ...

  9. java.io.file

    package cn.edu.tongji.cims.wade.system;     import java.io.*;     public class FileOperate {     pub ...

  10. Java开发必会的Linux命令

    Java开发必会的Linux命令 作为一个Java开发人员,有些常用的Linux命令必须掌握.即时平时开发过程中不使用Linux(Unix)或者mac系统,也需要熟练掌握Linux命令.因为很多服务器 ...

随机推荐

  1. 「BJWC2012」冻结题解

    「BJWC2012」冻结题解 一.题目 "我要成为魔法少女!" "那么,以灵魂为代价,你希望得到什么?" "我要将有关魔法和奇迹的一切,封印于卡片之中 ...

  2. WPF实现Element UI风格的日期时间选择器

    背景 业务开发过程中遇到一个日期范围选择的需求,和Element UI的DateTimePicker组件比较类似,由两个日历控件组成,联动选择起始时间和结束时间. 问题 WPF中提供了一个DatePi ...

  3. SpringBoot - 自定义starter

    目录 一.什么是SpringBoot starter机制 二.为什么要自定义starter 三.什么时候需要创建自定义starter 四.自动加载核心注解说明 五.自定义starter的开发流程 案例 ...

  4. Vue【原创】下划线动态效果按钮,一般按钮模式,开关切换模式

    效果图: 1.icon-button 一般按钮模式: 1 <template> 2 <div class="icon-button" :style="{ ...

  5. WEB组态编辑器插件(BY组态)介绍

    BY组态是一款非常优秀的纯前端的[web组态插件工具],采用标准HTML5技术,基于B/S架构进行开发,支持WEB端呈现,支持在浏览器端完成便捷的人机交互,简单的拖拽即可完成可视化页面的设计.可无缝嵌 ...

  6. 基于.Net 的 AvaloniUI 多媒体播放器方案汇总

    基于.Net 的 AvaloniUI 多媒体播放器方案汇总 摘要 随着国产化的推进,相信.Net的桌面端的小伙伴的可能已经有感受到了. 为了让.Net的桌面框架能够跨桌面平台,首选的就是Avalona ...

  7. python~windows自动化工具 uiautomation库

    微软提供了关于自动化操作PC端桌面应用程序的工具,官方描述为: Microsoft UI Automation is an accessibility framework that enables W ...

  8. 使用 DDPO 在 TRL 中微调 Stable Diffusion 模型

    引言 扩散模型 (如 DALL-E 2.Stable Diffusion) 是一类文生图模型,在生成图像 (尤其是有照片级真实感的图像) 方面取得了广泛成功.然而,这些模型生成的图像可能并不总是符合人 ...

  9. 练习回—编译安装nginx

    练习回 练习,编译安装nginx. 1.yum安装依赖环境 yum -y install pcre-devel zlib-devel gcc gcc-c++ make 2."下载" ...

  10. 【腾讯云 HAI域探秘】探索AI绘画之路:利用腾讯云HAI服务打造智能画家

    前言 随着人工智能的飞速发展,AI在艺术创作领域的应用正经历着一场革命性的变革.在这个数字时代,腾讯云的高性能应用服务HAI(Hyper Application Inventor)为艺术家和创作者提供 ...