ural 1563. Bayan(水题)

http://acm.timus.ru/problem.aspx?space=1&num=1563

1563. Bayan

Time Limit: 1.0 second
Memory Limit: 64 MB
Problem illustration
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 next  N  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
题意:求一组字符串出现不重复的个数(水题)
 
      
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
char s[1010][50];
int vis[1010][1010];
int main() {
        int n;
        while (scanf("%d", &n) != EOF) {
                getchar();
                memset(vis, 0, sizeof(vis));
                for (int i = 0; i < n; i++) {
                        gets(s[i]);
                }
                // sort(s[50],s[50]+n);
                //int N;
                //N=unique(s[50],s[50]+n)-s[50];
                //printf("%d\n",N);
                int count = 0;
                for (int i = 0; i < n; i++) {
                        for (int j = i + 1; j < n; j++) {
                                if (strcmp(s[i], s[j]) == 0 && strcmp(s[i], "\0") != 0) {
                                        count++;
                                        strcpy(s[j], "\0");
                                }
                        }
                }
                printf("%d\n", count);
        }
        return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值