ACM_水题你要信了(修改版)
水题你要信了
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_水题你要信了(修改版)的更多相关文章
- ACM_水题你信吗
水题你信吗 Time Limit: 2000/1000ms (Java/Others) Problem Description: 某发最近又认识了很多妹(han)子,可是妹(han)子一多不免有时会忘 ...
- [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]
Three Families Three families share a garden. They usually clean the garden together at the end o ...
- [ACM_水题] Yet Another Story of Rock-paper-scissors [超水 剪刀石头布]
Description Akihisa and Hideyoshi were lovers. They were sentenced to death by the FFF Inquisition. ...
- [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 ...
- [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 ...
- [ACM_水题] ZOJ 3706 [Break Standard Weight 砝码拆分,可称质量种类,暴力]
The balance was the first mass measuring instrument invented. In its traditional form, it consists o ...
- [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 ...
- [ACM_水题] ZOJ 3712 [Hard to Play 300 100 50 最大最小]
MightyHorse is playing a music game called osu!. After playing for several months, MightyHorse disco ...
- [ACM_水题] 不要62(hdu oj 2089, 不含62和4的数字统计)
Problem Description 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来, ...
随机推荐
- CSC
CSC CSC Table of Contents 1. account 2. Contacts 3. <国家公派留学人员预订回国机票说明> 4. 回国手续 4.1. 申办及开具<留 ...
- Authors and instutes in MCT
Authors and instutes in MCT Table of Contents 1. Authors and Institutes 1.1. Industry 1 Authors and ...
- 7-26 Windows消息队列
7-26 Windows消息队列(25 分) 消息队列是Windows系统的基础.对于每个进程,系统维护一个消息队列.如果在进程中有特定事件发生,如点击鼠标.文字改变等,系统将把这个消息加到队列当中. ...
- [spoj1182][Sorted Bit Sequence] (数位dp)
Description Let's consider the 32 bit representation of all integers i from m up to n inclusive (m ≤ ...
- Windows学习总结(10)——Windows系统中常用的CMD命令详解
1.ping命令 ping是电脑网络故障诊断中的常用的命令,它的作用是用来检查网络是否通畅或者网络连接速度.我们来看一下PING命令的具体表述. 日常的诊断过程中我们最常用到的就是诊断连接是否通畅. ...
- UVA 12686 Trending Topic
Trending Topic Time limit: 1.000 seconds Imagine you are in the hiring process for a company whose p ...
- Tensorflow Eager execution and interface
Lecture note 4: Eager execution and interface Eager execution Eager execution is (1) a NumPy-like li ...
- hdu 2546 0-1背包
#include<stdio.h> #include<string.h> #define N 1100 int dp[N],a[N]; int main() { int n,m ...
- UVa - 12450 - SpaceRecon Tournament
先上题目: Problem G: SpaceRecon Tournament SpaceRecon, the hottest game of 2011, is a real-time strategy ...
- 小L 的二叉树(洛谷 U4727)
题目背景 勤奋又善于思考的小L接触了信息学竞赛,开始的学习十分顺利.但是,小L对数据结构的掌握实在十分渣渣. 所以,小L当时卡在了二叉树. 题目描述 在计算机科学中,二叉树是每个结点最多有两个子结点的 ...