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 ...
随机推荐
- 2012-2013 ACM-ICPC, NEERC, Central Subregional Contest C Sequence (打表)
打个表找找规律,到24445的时候乘2以后产生了0出现循环. 一般地,判断循环节是否存在可以用Floyd判圈算法. #include<bits/stdc++.h> using namesp ...
- 集成iAd广告
在iPhone程序中集成广告,管他能不能赚钱,不放上一个iAd就心有不甘. 参考了下面这篇文章: http://bees4honey.com/blog/tutorial/how-to-add-iad- ...
- C#编写高并发数据库控制
往往大数据量,高并发时, 瓶颈都在数据库上, 好多人都说用数据库的复制,发布, 读写分离等技术, 但主从数据库之间同步时间有延迟.代码的作用在于保证在上端缓存服务失效(一般来说概率比较低)时,形成倒瓶 ...
- VC-基础:关于一些符号的意义
GUI应用程序:Graphic User Interface图形 用户 接口 SDI:单文档程序(典型的记事本就是SDI) MID:多文档程序(比如VS2008默认就是多文档的)
- ios之UILabel
详细使用: UILabel *label = [[UILabelalloc] initWithFrame:CGRectMake(0, 0, 75, 40)]; //声明UIlbel并指定其位置和长 ...
- 【数位dp】bzoj1799: [Ahoi2009]self 同类分布
各种奇怪姿势的数位dp Description 给出a,b,求出[a,b]中各位数字之和能整除原数的数的个数. Sample Input 10 19 Sample Output 3 HINT [约束条 ...
- linux中复制文件夹的所有文件到指定目录
这里我们的需求是需要将一个文件夹中的所有文件都复制到另一个文件夹中,而不是将一个文件夹复制到另外一个文件夹中. //这里需要使用到-R参数,表示递归处理,将指定目录下的所有文件与子目录一并处理//一开 ...
- java获取本地计算机MAC地址
java获取本地计算机MAC地址代码如下: public class SocketMac { //将读取的计算机MAC地址字节转化为字符串 public static String transByte ...
- usb3.0驱动
usb3.0驱动下载地址 华硕注入usb3.0驱动工具下载地址 https://dlsvr04.asus.com/pub/ASUS/misc/utils/ASUS_EZInstaller_V10306 ...
- modelsim安装调试
modelsim,debug:“unable to checkout a viewer license necessary for use of the modelsim graphical user ...