CSU 1505: 酷酷的单词【字符串】
Description
输入一些仅由小写字母组成的单词。你的任务是统计有多少个单词是“酷”的,即每种字母出现的次数都不同。
比如ada是酷的,因为a出现2次,d出现1次,而1和2不同。再比如,banana也是酷的,因为a出现3次,n出现2次,b出现1次。但是,bbacccd不是酷的,因为a和d出现的次数相同(均为1次)。
Input
输入包含不超过30组数据。每组数据第一行为单词个数n (1<=n<=10000)。以下n行各包含一个单词,字母个数为1~30。
Output
对于每组数据,输出测试点编号和酷单词的个数。
Sample Input
2
ada
bbacccd
2
illness
a
Sample Output
Case 1: 1
Case 2: 0
Hint
Source
湖南省第十届大学生计算机程序设计竞赛
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<set>
#include<map>
#include<sstream>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<vector>
#include<string>
using namespace std;
#define ll long long
const double PI = acos(-1.0);
const double eps = 1e-;
const int inf = 0x3f3f3f3f;
const int N = ;
const int mod = ;
int n, m, tot;
/*
4
ada
bbacccd
illness
a
*/
int mp[]; int t;
char str[];
int main()
{
int k = ;
while(scanf("%d",&t)!=EOF)
{
int cnt = ;
while(t--)
{
int f = ;
scanf("%s",&str);
memset(mp,,sizeof(mp));
if(strlen(str) == ) f = ;
else{
for(int i=; str[i]; i++)
mp[str[i]-'a']++;
for(char i=; i<; i++)
{
for(int j=i+; j<; j++)
{
if(mp[j] == mp[i] && mp[i] != )
{
f = ;break;
}
}
}
if(f==) cnt++;
}
}
printf("Case %d: %d\n",k++,cnt);
}
return ;
}
AC
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<set>
#include<map>
#include<sstream>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<vector>
#include<string>
using namespace std;
#define ll long long
const double PI = acos(-1.0);
const double eps = 1e-;
const int inf = 0x3f3f3f3f;
const int N = ;
const int mod = ;
int n, m, tot;
/*
4
ada
bbacccd
illness
a
*/
int a[N];
int t;
map<int,int> mp;
vector<int> v;
char str[];
int main()
{
int k = ;
while(cin>>t)
{
mp.clear();
v.clear();
int cnt = ;
while(t--)
{
int f = ;
cin>>str;
if(strlen(str) == ) f = ;
else{
for(int i=; str[i]; i++)
mp[str[i]-'a']++; for(char i=; i<; i++)
if(mp[i]!=)
v.push_back(mp[i]);
int num = v.size();//原来单词出现次数1 2(2)/1 1 2 3
sort(v.begin(),v.end());
v.erase(unique(v.begin(), v.end()), v.end());
if(num == v.size())
f = ;
}
if(f) cnt++;//每种字母出现的次数都不同。
}
printf("Case %d: %d\n",k++,cnt);
}
return ;
} /*
for(map<char, int>::iterator iter = mp.begin(); iter != mp.end(); iter++) {
cout << iter->first << " : " << iter->second << endl;
} for(char i='a'; i<='z'; i++){
v.push_back(mp[i]);
}
/*
for(vector<int>::iterator it = v.begin(); it!=v.end(); it++)
cout<<*it<<" ";
cout<<endl;*/ /**********************************************************************
Problem: 1505
User: roniking
Language: C++
Result: TLE
**********************************************************************/
TLE(STL
CSU 1505: 酷酷的单词【字符串】的更多相关文章
- csuoj 1505: 酷酷的单词
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1505 1505: 酷酷的单词 时间限制: 1 Sec 内存限制: 128 MB 提交: 340 ...
- CSU 1505 酷酷的单词 湖南省赛第十届题目
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1505 题意:技巧题,就是一行字符串中,每个字母出现的次数互不相同,复即为酷的单词. 解题 ...
- BZOJ3172 [Tjoi2013]单词 字符串 SA ST表
原文链接http://www.cnblogs.com/zhouzhendong/p/9026543.html 题目传送门 - BZOJ3172 题意 输入$n(n\leq 200)$个字符串,保证长度 ...
- 【bzoj3172】: [Tjoi2013]单词 字符串-AC自动机
[bzoj3172]: [Tjoi2013]单词 先用所有单词构造一个AC自动机 题目要求的是每个单词在这个AC自动机里匹配到的次数 每次insert一个单词的时候把路径上的cnt++ 那么点p-&g ...
- 酷酷的CSS3三角形运用
概述 在早期的前端Web设计开发年代,完成一些页面元素时,我们必须要有专业的PS美工爸爸,由PS美工爸爸来切图,做一些圆角.阴影.锯齿或者一些小图标. 在CSS3出现后,借助一些具有魔力的CSS3属性 ...
- 酷酷的mapv
做城市热力图的时候无意浏览到mapv强大的功能.比如地图上路线的汇聚效果,如下 <!DOCTYPE html> <html> <head> <meta cha ...
- 酷酷的jQuery classicAccordion 手风琴
在线实例 效果一 效果二 效果三 使用方法 手风琴ul li列表 <ul class="accordion"> <li> < ...
- 【转载】酷酷的CSS3三角形运用
转载:http://www.cnblogs.com/keepfool/p/5616326.html 概述 在早期的前端Web设计开发年代,完成一些页面元素时,我们必须要有专业的PS美工爸爸,由PS美工 ...
- [ios]ipad下的splitViewController 让你的APP看起来酷酷的!
在ipad下可以使用splitViewController splitViewController下包含两个viewController 这是一种将屏幕一分为二的方式. 在水平状态下会出现成两个左右两 ...
随机推荐
- poj 3259 时光穿梭问题 bellman_ford算法
题意:有n个空地,有m条双向大路,w条时光隧道单向路.问能否回到过去? 思路:判断是否有负环存在,如果有负环存在那么就可以一直小就可以回到过去了 创建源顶点 V到其他顶点的距离d 初始为INF d[1 ...
- 2、大O表示法
一.大O表示法 大O表示法不是一种算法.它是用来表示一个算法解决问题的速度的快慢.一般我们描述一件事情完成的快慢是用时间描述的,比如说我完成一道计算题用了多少分钟.但算法的运算是很难用准确的时间来描述 ...
- python-PIL模块的使用
PIL基本功能介绍 from PIL import Image from PIL import ImageEnhance img = Image.open(r'E:\img\f1.png') img. ...
- U10783 名字被和谐了
U10783 名字被和谐了 题目背景 众所周知,我们称g是a的约数,当且仅当g是正数且a mod g = 0. 众所周知,若g既是a的约数也是b的约数,我们称g是a.b的一个公约数. 众所周知,a.b ...
- Springmvc 重定向参数传递方式
Springmvc 通过return "redirect:" 实现重定向 重定向的状态码301 302 301,302 都是HTTP状态的编码,都代表着某个URL发生了转移 ...
- Tensorflow打造聊天机器人
Tensorflow聊天机器人 聊天机器人也叫做对话系统,是一个热门领域.微软.facebook.苹果.google.微信.slack都在上面做了大的投入,这是一波新的试图改变人和服务交流的创业浪潮. ...
- 解决This application failed to start because it could not find or load the Qt platform plugin "windows
解决方案:所在环境python根目录下qt.conf,重新设置path即可,此类问题通常在目录转移之后出现.
- Leetcode 553.最优除法
最优除法 给定一组正整数,相邻的整数之间将会进行浮点除法操作.例如, [2,3,4] -> 2 / 3 / 4 . 但是,你可以在任意位置添加任意数目的括号,来改变算数的优先级.你需要找出怎么添 ...
- [python][django学习篇][2]创建django app
推荐学校django博客:http://pythonzh.cn/post/8/ django app 可以理解为一个文件夹: 里面包含了相关功能的代码.通过manage.py来创建 web app 激 ...
- android下拉弹出动画
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http:// ...