URAL 1563. Bayan (STL map)

1563. Bayan

Time limit: 1.0 second

Memory limit: 64 MB

As everybody knows, there are a lot of stores in skyscrapers, it‘s the favourite place of glamorous girls. Blonde Cindy loves only one thing — the shopping. Today is one of the best days, she‘s going shopping to the new skyscraper
“Prisma”. At first she decided to visit all the stores. But actually the “Prisma” is so large that you can find not just one store of each brand. Every time when Cindy found the brand, she has visited before, she told “Bayan”, and went on shopping.

Cindy saw all the stores in the “Prisma”. So how many times did she tell “Bayan”?

Input

First line contains single integer N representing the number of stores in the “Prisma” (1 ≤ N ≤ 1000). In each of nextN lines the brand of store is written. The brands are the strings of Latin letters
and blanks. The length of the string is from 1 to 30. There are no brands, that differ only in register.

Output

Print the number of stores, Cindy didn‘t visit.

Sample

input output
12
ESPRIT
Nice Connection
Camelot
Adilisik
Lady and Gentleman City
MEXX
Camelot
Sultanna Frantsuzova
Camaieu
MEXX
Axara
Camelot
3

Problem Author: Vladimir Yakovlev

Problem Source: The XIIth USU Programing Championship, October 6, 2007

解析:当一个字符串在之前已经出现过时,说一次“Bayan”。用getline()或者gets()都可以读,要注意空格和换行。

PS:之前一直wrong,原来是题意理解错了。。。

AC代码:

#include <cstdio>
#include <map>
#include <string>
#include <iostream>
using namespace std;

map<string, int> m;

int main(){
    #ifdef sxk
        freopen("in.txt", "r", stdin);
    #endif //sxk

    int n;
    string s;
    while(scanf("%d", &n)==1){
        getchar();
        int ans = 0;
        m.clear();
        for(int i=0; i<n; i++){
            getline(cin, s);
            if(m.count(s)) ans ++;   //出现过
            m[s] ++;
        }
        printf("%d\n", ans);
    }
    return 0;
}
时间: 2024-10-12 09:18:16

URAL 1563. Bayan (STL map)的相关文章

HDU 4585 Shaolin(STL map)

Shaolin Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4585 Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a mon

【POJ 3274】Gold Balanced Lineup (stl map )设计hash表,处理碰撞

题目链接 题目链接 http://poj.org/problem?id=3274 题意 输入每头牛的特征的10进制,若i~j头牛中每个数位的特征相等则满足要求,求所有满足要求的j-i的最大值. 解题思路 抽屉原理,用前缀和处理每个数位即可. 直接暴力的话复杂度太大了,所以需要取巧的办法. 直接暴力求解是sum[i][p] - sum[j][p] == sum[i][0] - sum[j][0].其中i表示第i头牛,j表示第j头牛,p表示第p个特征,i > j. 取巧的办法:sum[i][p] -

Codeforces--670C--Cinema(STL map)

 Cinema Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Moscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists kn

HDU 2072 单词数 (STL map)

单词数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 34960    Accepted Submission(s): 8380 Problem Description lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数.下面你的任务是帮助xiaoou333解决这个问题. Inp

hdu 4941 Magical Forest(STL map &amp; 结构体运用)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4941 Magical Forest Time Limit: 24000/12000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 220    Accepted Submission(s): 105 Problem Description There is a forest c

D3.js数据可视化(一)——绘制热图(heat map)

二维标量可视化 1. 实验名称 二维标量的可视化. 2. 实验目的 使用d3以及提供的NBA篮球上个赛季的数据(basketball statics.xlsx),绘制一个热图(heat map). 3. 技术基础 Web, HTML, DOM, CSS, JavaScript, SVG. 核心技术为D3 —— Data-Driven Documents(数据驱动的文档).数据来源于你,而文档就是基于Web的文档(或者网页),代表可以在浏览器中展现的一切,比如HTML,SVG.D3扮演的是一个驱动

hdu4941 Magical Forest (stl map)

2014多校7最水的题   Magical Forest Magical Forest Time Limit: 24000/12000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 253    Accepted Submission(s): 120 Problem Description There is a forest can be seen as N * M gri

阴影映射(Shadow Map)的研究(二)

阴影映射(Shadow Map)的研究(二) 上一篇文章介绍了我对Z缓存的较为详细的研究.这里之所以对Ze求导函数,是因为的我们需要寻找它的变化曲线,从而找到极值点,这样就能够确定Ze相对于zw的疏密分布情况.幸运的是,我们找到的导函数是双曲函数,并且我们关心的的右侧是单调递增的. 蒋彩阳原创文章,首发地址:http://blog.csdn.net/gamesdev/article/details/44946763.欢迎同行前来探讨. 引出上一篇文章的结论,当 时,导函数取得最大值.但是在Zw∈

【Unity Shader】使用法线贴图(Normal Map)的Shader

为何要用法线贴图 为了提升模型表现细节而又不增加性能消耗,所以不选择提高模型的面数,而是给模型的材质Shader中使用上法线贴图(Normal Map),通过更改模型上的点的法线方向,增加光影凹凸效果,从而提升模型表现细节.使用法线贴图能使一个三角面表现出凹凸的视觉效果! 法线贴图原理 http://www.cnblogs.com/tekkaman/p/3992352.html 上面的文章解释了很多问题: 法线被存储在切线空间(Tangent Space Normal)中,所以法线贴图看上去呈蓝