水题你要信了

Time Limit: 2000/1000ms (Java/Others)

Problem Description:

某发最近又认识了很多妹(han)子,可是妹(han)子一多不免有时会忘记那么一两个,为了记得他们的名字,发哥设计了一个记录器。对于每个他刚认识的妹(han)子,他都把妹子的名字放进记录器里,如果记录器已经有这个妹子的名字,则在这个妹子的名字后面加上一个数字(数字从1开始),输出妹子的名字加上数字。若记录器没有这个妹子的记录,则输出OH GOD。

Input:

(EOF)输入一个数字n表示发哥认识的妹子(1<=N<=10^5),接下来n行每行一个字符串,字符串不超过100个小写字母。

Output:

如描述。

Sample Input:

6
first
first
second
second
third
first

Sample Output:

OH GOD
first1
OH GOD
second1
OH GOD
first2
解题思路:map容器过,并且要用c语言的输入输出,不然老是超时=_=||。map查找时间为O(logn),总的时间复杂度是O(nlogn)。同样的题目(这题的字符串长度比原来扩大了1倍)链接:ACM_水题你信吗
AC代码:(225ms)
 #include<bits/stdc++.h>
using namespace std;
int main(){
int t;string str;str.resize();//预先分配空间101
while(~scanf("%d",&t)){
getchar();map<string,int> mp;
while(t--){
scanf("%s",&str[]);//string类用scanf读取
if(mp.find(str)==mp.end()){printf("OH GOD\n");mp[str]++;}
else printf("%s%d\n",str.c_str(),mp[str]++);//string类用c语言格式输出
}
}
return ;
}

ACM_水题你要信了(修改版)的更多相关文章

  1. ACM_水题你信吗

    水题你信吗 Time Limit: 2000/1000ms (Java/Others) Problem Description: 某发最近又认识了很多妹(han)子,可是妹(han)子一多不免有时会忘 ...

  2. [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]

      Three Families  Three families share a garden. They usually clean the garden together at the end o ...

  3. [ACM_水题] Yet Another Story of Rock-paper-scissors [超水 剪刀石头布]

    Description Akihisa and Hideyoshi were lovers. They were sentenced to death by the FFF Inquisition. ...

  4. [ACM_水题] UVA 11729 Commando War [不可同时交代任务 可同时执行 最短完成全部时间 贪心]

    There is a war and it doesn't look very promising for your country. Now it's time to act. You have a ...

  5. [ACM_水题] UVA 11292 Dragon of Loowater [勇士斗恶龙 双数组排序 贪心]

    Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shor ...

  6. [ACM_水题] ZOJ 3706 [Break Standard Weight 砝码拆分,可称质量种类,暴力]

    The balance was the first mass measuring instrument invented. In its traditional form, it consists o ...

  7. [ACM_水题] ZOJ 3714 [Java Beans 环中连续m个数最大值]

    There are N little kids sitting in a circle, each of them are carrying some java beans in their hand ...

  8. [ACM_水题] ZOJ 3712 [Hard to Play 300 100 50 最大最小]

    MightyHorse is playing a music game called osu!. After playing for several months, MightyHorse disco ...

  9. [ACM_水题] 不要62(hdu oj 2089, 不含62和4的数字统计)

    Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来, ...

随机推荐

  1. 第九节:web爬虫之urllib(五)

    第四个模块 robotparser: 主要是用来识别网站的 robots.txt 文件,然后判断哪些网站可以爬,哪些网站不可以爬的,其实用的比较少.

  2. Wind rotor states

    test test Table of Contents 1. Wind rotor states 1.1. Turbulent Wake State 1.2. Vortex Ring State 1. ...

  3. 关于vuex自己理解的三幅图

  4. PAT 1139 First Contact

    Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle i ...

  5. 【03】全局 CSS 样式

    全局 CSS 样式 设置全局 CSS 样式:基本的 HTML 元素均可以通过 class 设置样式并得到增强效果:还有先进的栅格系统. 概览 深入了解 Bootstrap 底层结构的关键部分,包括我们 ...

  6. UVALive 6510 Stickers

    Stickers Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ...

  7. Contemplation! Algebra 矩阵快速幂

    Given the value of a+b and ab you will have to find the value of a n + b n Input The input file cont ...

  8. 8、Java并发性和多线程-静态条件与临界区

    以下内容转自http://ifeve.com/race-conditions-and-critical-sections/: 在同一程序中运行多个线程本身不会导致问题,问题在于多个线程访问了相同的资源 ...

  9. SfM环境的搭建windows8.1+vs2010

    SfM即Structure form Motion,这个算法的实现,作者Noah Snavely给出了一个具体的实现. 目前最新下载https://github.com/snavely/bundler ...

  10. ssh2项目整合 struts2.1+hibernate3.3+spring3 基于hibernate注解和struts2注解

    项目文件夹结构例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveW9uZ3poaWFu/font/5a6L5L2T/fontsize/400/fi ...