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 ...
随机推荐
- FusionCharts3.2.1 参数的详细说明和功能特性
功能特性animation 是否动画显示数据,默认为1(True)showNames 是否显示横向坐标轴(x轴)标签名称rotat ...
- Windows系统下如何优化Android Studio
Android Studio将是Android开发大势所趋. 安装Android Studio时需注意的细节: · 找到安装目录bin目录下idea.properties 最后一行加入: dis ...
- WPF知识点全攻略08- 依赖属性
依赖属性是WPF不得不提,不得不会系列又一 先来看一下,自定义依赖属性的写法 public static readonly DependencyProperty IconProperty = Depe ...
- StringMVCWeb接受前台值的几种方式
这些决定与request header 的Content-Type属性 1.通过@RequestParam @RequestParam Map<String, Object> pa ...
- lucene4.7实例详解
java.lang.UnsupportedClassVersionError: org/apache/lucene/index/IndexableField : Unsupported major.m ...
- PAT 乙级 1005
题目 题目地址:PAT 乙级 1005 题解 本题主要就在于将一个数的一系列计算结果不重复地存储起来并便于检索,考虑到STL中的集合有相似的特性,使用set可以有效地简化代码和运算. 过程如下: (初 ...
- 【Java_基础】并发、并行、同步、异步、多线程的区别
1. 并发:位于同一个处理器上的多个已开启未完成的线程,在任意一时刻系统调度只能让一个线程获得CPU资源运行,虽然这种调度机制有多种形式(大多数是以时间片轮巡为主).但无论如何,都是通过不断切换需要运 ...
- (14)zabbix Simple checks基本检测
1. 开始 Simple checks通常用来检查远程未安装代理或者客户端的服务 使用simple checks,被监控客户端无需安装zabbix agent客户端,zabbix server直接使用 ...
- 蓝牙学习 (7) - raspberrryPi 扫描TI sensorTag
前面几篇分别简单涉及了 raspberryPi上bluez BLE sniffer TI SensorTag https://blog.csdn.net/feiwatson/article/detai ...
- 刚毕业去面试Python工程师,这几道题太难了,Python面试题No11
写在前面 本想停一段时间这个系列,但是好多朋友给我发信息说让我继续整理下去,so,继续吧~ 第1题: docstring是什么? docstring是一种文档字符串,用于解释构造的作用.我们在函数.类 ...