poj2945 Find the Clones
| Time Limit: 5000MS | Memory Limit: 65536K | |
| Total Submissions: 8490 | Accepted: 3210 |
Description
Input
The input is terminated by a block with n = m = 0 .
Output
Sample Input
9 6
AAAAAA
ACACAC
GTTTTG
ACACAC
GTTTTG
ACACAC
ACACAC
TCCCCC
TCCCCC
0 0
Sample Output
1
2
0
1
0
0
0
0
0
Hint
Source
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int n, len, tot, ans[];
char s[]; struct node
{
int tr[];
int end;
void clear()
{
memset(tr, , sizeof(tr));
end = ;
}
}e[]; void insert(char *ss)
{
int u = ;
for (int i = ; i <= len; i++)
{
if (!e[u].tr[ss[i] - 'A'])
e[u].tr[ss[i] - 'A'] = ++tot;
u = e[u].tr[ss[i] - 'A'];
}
e[u].end++;
} int main()
{
while (scanf("%d%d", &n, &len) && (n || len))
{
memset(ans, , sizeof(ans));
for (int i = ; i <= tot; i++)
e[i].clear();
tot = ;
for (int i = ; i <= n; i++)
{
scanf("%s", s + );
insert(s);
}
for (int i = ; i <= tot; i++)
ans[e[i].end]++;
for (int i = ; i <= n; i++)
printf("%d\n", ans[i]);
} return ;
}
poj2945 Find the Clones的更多相关文章
- POJ2945 Find the Clones trie树
建一颗$trie$树(当然你哈希也资瓷),边插边更新,看看搜到最底时有多少个字符串,然后更新. #include<cstdio> #include<iostream> #inc ...
- POJ2945(Find the Clones)--字典树,map
题意:给你n个规定长度的单词,问你其中出现了1次的单词,出现两次的单词...出现n次单词分别有多少个. 当然这题map也能过,但是这里介绍字典树的做法. 首相对于n个单词存入树中,当然建树过程中遇到一 ...
- POJ2945:Find the Clones——题解
http://poj.org/problem?id=2945 还是trie树……对于结束标记累加并且开个数组记录一下即可. #include<cstdio> #include<cst ...
- Find the Clones
Find the Clones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 6365 Accepted: 2375 D ...
- poj 2945 Find the Clones
https://vjudge.net/problem/POJ-2945 题意: 给出n个长度相同的DNA序列,如果一个DNA序列出现过两次,那么就有说明它被复制了一次.问被复制0次,1次,2次--n- ...
- Apache Tomcat 9 Installation on Linux (RHEL and clones)
Apache Tomcat 9 is not available from the standard RHEL distributions, so this article provides info ...
- XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem D. Clones and Treasures
题目:Problem D. Clones and TreasuresInput file: standard inputOutput file: standard outputTime limit: ...
- 【hdu2222】【poj2945】AC自动机入门题
HDU2222 传送门 题目分析 裸题:注意构建自动机用的是模式串,思想和kmp很类似. code: #include<iostream> #include<cstdio> # ...
- 用链式字典树解决POJ2945
首先,我们的思路是用链式的字典树结构,解决poj2945这道题 题意是,统计所有的字符串出现的次数,并依次输出各个次数的数量 例如: input 9 6AAAAAAACACACGTTTTGACACAC ...
随机推荐
- win7下如何解决协议适配器错误问题
数据库为oracle 11g,在cmd中使用sqlplus命令出现了“协议适配器错误”. 原因分析:oracle相关服务没有启动. 解决办法如下: step1:进入服务页面. 方法一:cmd → se ...
- 使用Azure CDN更快速的交付内容
WEB加速服务是最基本也是应用最广泛的CDN加速服务,主要针对html文件,CSS,图片,JS,flash动画等更新频率低的小文件加速.通过将这些小文件缓存到Azure CDN的边缘节点,减少源站的访 ...
- SQL还原数据库
还原一个备份数据库的经历. 首先,手头上有工程文件及相应的数据库的备份. 步骤: 1.在工程文件里找到配置文件,我这个是在bin目录里找到config.ini 2.双击打开它,里面有一些数据库的相关信 ...
- Spring MVC能响应HTTP请求的原因?
很多Java面试官喜欢问这个问题: 一个Spring MVC的项目文件里,开发人员没有开发自己的Servlet,只通过注解@RequestMapping定义了方法home能响应发向 /mvc/test ...
- 双击窗体是模拟键盘上的Tab键
实现效果: 知识运用: SendKeys类的Send方法 //向活动应用程序发送击键 public static void Send (string keys) 实现代码: private void ...
- 在Terminal中,如何打开Finder,并显示当前的目录
这是一个非常方便实用的小技巧,在Terminal中输入如下命令: $ open . 有图有真相: 参考: Open Finder in Current Folder from Terminal
- MFC:AfxParseURL
BOOL AFXAPI AfxParseURL( LPCTSTR pstrURL, DWORD& dwServiceType, CString& strServ ...
- BestCoder Round#15 1001-Love
http://acm.hdu.edu.cn/showproblem.php?pid=5082 Love Time Limit: 2000/1000 MS (Java/Others) Memory ...
- vs code背景图片的设置
使用vs code编辑器的时候,每次看到黑色的背景,会感觉到很大的视觉疲劳,今天来换换背景来看下效果 你需要安装的插件是background 然后在文件 => 首选项 => 设置搜索bac ...
- docker系列之基础命令-2
一.查看本地镜像 docker images 二.需要基础的镜像两种方式 1.docker pull centos 可以直接拉起镜像 2.直接用xshell导入就行,docker load -i 加 ...