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 ...
随机推荐
- Selenium私房菜系列5 -- 第一个Selenium RC测试案例
<Selenium简介>中讲过,Selenium RC支持多种语言编写测试案例,如:C#,Python.在工作中,我倾向于是用Python这类动态语言编写测试案例,因为这样的测试案例无需编 ...
- chm文件帮助功能全解
在winform中点击某个按钮弹出关于这个窗体的功能的具体解释文档方法如下: 第一步,使用chm编译工具修改chm每个文档的url 修改完成后保存确认能否打开, 如果不能就使用这个软件的转换功能把ch ...
- SpringBoot整合Thymeleaf
一个整合Thymeleaf与Mybatis的CRUD例子 整合Mybatis例子 一.添加maven依赖 <dependency> <groupId>org.springfra ...
- POI写入word docx 07 的两种方法
下载最新jar包:http://poi.apache.org/download.html 以及API 1.写入word 1.1 直接通过XWPFDocument生成 在使用XWPFDocument写d ...
- Python IDE推荐
八个最佳Python IDE 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs Python是一种功能强大.语言简洁的编程语言.本文向大家推荐8个适合pyt ...
- java mongodb 增删改查 工具类
package com.jttx.demo; import com.mongodb.*; import com.mongodb.util.JSON; import java.net.Unkno ...
- Oracle数据库同步方案
Oracle数据库同步方案 1. 利用数据泵导出每表前2000行数据 expdp tvpay2/tvpay directory=dmp dumpfile=20170508.dmp include=ta ...
- ios retain copy assign相关
assign: 简单赋值,不更改索引计数copy: 建立一个索引计数为1的对象,然后释放旧对象retain:释放旧的对象,将旧对象的值赋予输入对象,再提高输入对象的索引计数为1 Copy其实是建立了一 ...
- 【贪心 思维题】[USACO13MAR]扑克牌型Poker Hands
看似区间数据结构的一道题 题目描述 Bessie and her friends are playing a unique version of poker involving a deck with ...
- [CODEVS] 3955 最长严格上升子序列(加强版)
题目描述 Description 给一个数组a1, a2 ... an,找到最长的上升降子序列ab1<ab2< .. <abk,其中b1<b2<..bk. 输出长度即可. ...