poj 2945 Find the Clones

Android 车载应用开发与优化(1) - CarLauncher 核心功能与动态集成探秘 本文深入探讨了Android车载应用开发中CarLauncher的核心功能与实现原理。作为车载系统的“脸面”,CarLauncher不仅提供应用入口,更通过动态集成技术将地图、音乐等关键信息嵌入桌面,以保障驾驶安全与体验。文章详细解析了其源码结构、权限配置、应用启动机制以及基于Activity嵌入的动态集成黑魔法,为开发者提供了从基础认识到高级优化的完整指南。 阅读详情

Find the Clones
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 7145 Accepted: 2659

Description

Doubleville, a small town in Texas, was attacked by the aliens. They have abducted some of the residents and taken them to the a spaceship orbiting around earth. After some (quite unpleasant) human experiments, the aliens cloned the victims, and released multiple copies of them back in Doubleville. So now it might happen that there are 6 identical person named Hugh F. Bumblebee: the original person and its 5 copies. The Federal Bureau of Unauthorized Cloning (FBUC) charged you with the task of determining how many copies were made from each person. To help you in your task, FBUC have collected a DNA sample from each person. All copies of the same person have the same DNA sequence, and different people have different sequences (we know that there are no identical twins in the town, this is not an issue).

Input

The input contains several blocks of test cases. Each case begins with a line containing two integers: the number 1 ≤ n ≤ 20000 people, and the length 1 ≤ m ≤ 20 of the DNA sequences. The next n lines contain the DNA sequences: each line contains a sequence of m characters, where each character is either `A', `C', `G' or `T'. 

The input is terminated by a block with n = m = 0 .

Output

For each test case, you have to output n lines, each line containing a single integer. The first line contains the number of different people that were not copied. The second line contains the number of people that were copied only once (i.e., there are two identical copies for each such person.) The third line contains the number of people that are present in three identical copies, and so on: the i -th line contains the number of persons that are present in i identical copies. For example, if there are 11 samples, one of them is from John Smith, and all the others are from copies of Joe Foobar, then you have to print `1' in the first andthe tenth lines, and `0' in all the other lines.

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

Huge input file, 'scanf' recommended to avoid TLE. 


题目链接:http://poj.org/problem?id=2945


题目大意:给出n行由m个大写字母'A','G','T','C'组成的“基因片段”,输出n行,第i行输出基因片段重复出现i次的基因片段的个数。


解题思路:字典树+哈希。每个基因片段插入完成后在最后一个节点的cnt加1,表示该基因片段重复的次数,hash[cnt]++,表示重复出现cnt次的基因片段的个数。因为cnt的值是在更新的,所以当hash[cnt]值大于0时,要更新cnt值就要把原来hash[cnt]的值减去一个。


代码如下:


#include <cstdio>
#include <cstring>
char s[22];
int hash[20002];
struct node
{
    node *next[26];
    int cnt;
    node()
    {
        memset(next,0,sizeof(next));
        cnt=0;
    }
};
void Inseart(node *p,char *s)
{
    for(int i=0;s[i]!='\0';i++)
    {
        int a=s[i]-'A';
        if(p->next[a]==NULL)
            p->next[a]=new node();
        p=p->next[a];
    }
    if(hash[p->cnt])   //需要更新cnt值时hash值也要更新
        hash[p->cnt]--;
    p->cnt++;
    hash[p->cnt]++;
}
void clear(node *p)  //这题要释放空间,否则会超出内存
{
	for(int i=0;i<26;i++)
		if(p->next[i])
			clear(p->next[i]);
	delete p;
}

int main()
{
    int n,i,m;
    while(scanf("%d%d",&n,&m)&&(n||m))
    {
		node *root=new node();
        memset(hash,0,sizeof(hash));
        for(i=0;i<n;i++)
        {
            scanf("%s",s);
            Inseart(root,s);
        }
        for(i=1;i<=n;i++) //第i行输出重复出现次数为i的基因片段的个数。
        printf("%d\n", hash[i]);
		clear(root);
    }
	return 0;
}



SAP数据导入工具(LSMW) 超级详细教程(批量导入内部订单) 用户提了个需求,让我批量导入内部订单几百个内部订单。我本打算用写段ABAP 代码来调用 BAPI (BAPI_INTERNALORDER_CREATE)就可以了。但想到我很久没有用过LSMW 了,都快要忘记了。于是我采用LSMW的方式,完成了任务。并把过程记录下来,形成教程方便我以后回头查看,分享出来也希望对大家有帮助。 阅读详情

相关推荐

从零开始用QP框架开发STM32:事件驱动编程实战指南(附状态机设计技巧)

本文详细介绍了如何使用QP框架在STM32上实现事件驱动编程,包括状态机设计技巧和嵌入式开发实践。通过对比传统前后台系统和RTOS,展示了QP框架在资源占用、实时性和代码可维护性方面的优势,并提供了从环境搭建到高级状态机设计的完整指南。

h6i7j8的博客 1173

nyoj 285-寻找克隆人

http://acm.nyist.net/JudgeOnline/problem.php?pid=285 寻找克隆人 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 美国的一个小镇近日被外星人袭击,一部分居民被其带走并克隆,现在,科学家提取了镇上一些人的DNA,请找出其中具有相同被克隆个数的DNA个数,例如下面的9个序列

shofe的学习随记 837

【安装文档】TRex流量分析仪保姆级安装指南--基于VMware虚拟机(ubantu18.04@Intel 82545EM

如果之前添加了网卡,这里就可以看见有3个网卡(没添加的现在再加也行),* Active *为Linux内核正在使用的网卡,另外两张是未启用的网卡(注:未启用的网卡在终端中使用ifconfig命令是查不到的,需要先使用ip addr找出网卡,再激活,此时网卡会变为* Active *状态。

lingshengxiyou的博客 2130

poj2945

Find the Clones Time Limit:5000MS Memory Limit:65536K Total Submissions:5391 Accepted:1998 Description Doubleville, a small town in Texas, was attacked by t...

weixin_33967071的博客 204

NE5532A与JRC4580在低噪声音频电路设计中的关键应用

本文深入探讨了经典运算放大器NE5532A与JRC4580在低噪声音频电路设计中的核心应用。文章从噪声模型分析入手,阐述了针对低阻抗信号源时,如何利用这两款BJT输入运放的低电流噪声特性进行优化设计。通过对比两者参数与实战守则,为设计高保真音频前级、耳机放大等电路提供了从原理图到PCB布局的完整低噪声解决方案。

weixin_29295541的博客 326

解锁全志T113-i隐藏技能:用RISC-V核跑实时系统比STM32还稳?

本文深入探讨了全志T113-i SoC的异构架构潜力,重点解析如何利用其内置的玄铁C906 RISC-V核心独立运行实时系统。通过对比传统MCU与Linux方案,文章提供了从RISC-V核心启动、FreeRTOS移植到与Linux主核进行高效异构通信的完整实战指南,为工控等需要兼顾丰富应用与硬实时控制的场景提供了高集成度的单芯片解决方案。

ansible6ops的博客 494

poj 2945-关于字符串的排序

Find the Clones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions:6265   Accepted: 2328 Description Doubleville, a small town in Texas, was attacked by the al

桑榆 733

时序基础模型Timer-S1:十亿参数如何革新时间序列预测

时间序列预测是数据分析与机器学习中的核心任务,旨在基于历史数据预测未来趋势。其原理在于捕捉数据中的趋势、周期性和季节性等时序依赖关系。这项技术的价值在于赋能业务决策,广泛应用于金融风控、能源管理、物联网监控和供应链优化等关键场景。传统方法依赖针对特定任务的专用模型,面临泛化能力弱和开发成本高的挑战。本文聚焦的时序基础模型,通过在海量跨领域数据上进行预训练,学习时序通用模式,并结合十亿级参数带来的强大容量,实现了性能的显著突破。这种范式转变,使得模型能够像“全科医生”一样,通过少量数据微调即可快速适应新任务,

weixin_29164843的博客 268

NYOJ 285 寻找克隆人(map+计数)

题目描述  http://acm.nyist.net/JudgeOnline/problem.php?pid=285 美国的一个小镇近日被外星人袭击,一部分居民被其带走并克隆,现在,科学家提取了镇上一些人的DNA,请找出其中具有相同被克隆个数的DNA个数,例如下面的9个序列 AAAAAA ACACAC GTTTTG ACACAC GTTTTG ACACAC ACACAC

机器笨猫 1152

知识推理——TransE(知识表示、知识嵌入)

知识图谱嵌入/表示方法 TransE

missyoudaisy的博客 1831

FPGA 学习笔记:Vivado 工程更改FPGA 型号

FPGA 学习笔记:Vivado 工程更改FPGA 型号

坚韧与专注 1万+

杭电oj 2017 字符串的统计

#include <stdio.h> int main() { int n; char c,enter; scanf("%d%c",&n,&enter); //enter 接受回车键 while (n--) { int

888666 588

人体分割笔记总结

人体分割 人体分割(human parsing),属于语义分割任务的子任务,旨在对人类图像进行像素级的是细粒度分割(例如,划分出身体部位和服装)。根据不同的场景,又可以分为单人人体解析(single-person human parsing)和多人人体解析(multi-person human parsing,或者 instance-level human parsing)。除此之外,按照处理媒介分类,还可以分为基于图像的人体解析和基于视频的人体解析。 对于人体解析任务,常用的度量指标包括 Pixel a

jacke121的专栏 4255

POJ 2945 Find the Clones

题目描述 Doubleville, a small town in Texas, was attacked by the aliens. They have abducted some of the residents and taken them to the a spaceship orbiting around earth. After some (quite unpleasant)

CS练功房 1005

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

poj 2945 Find the Clones

Find the Clones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6663   Accepted: 2475 Description Doubleville, a small town in Texas, was attacked by the ali

liu_fanyi3的专栏 622

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

POJ2945——Find the Clones

Description Doubleville, a small town in Texas, was attacked by the aliens. They have abducted some of the residents and taken them to the a spaceship orbiting around earth. After some (quite unpleas

Alex 661

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

POJ2945 Find the Clones trie树

建一颗$trie$树(当然你哈希也资瓷),边插边更新,看看搜到最底时有多少个字符串,然后更新。 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<cctype&...

184

POJ 2945 Find the Clones

原题 http://poj.org/problem?id=2945 题目大意: 找出字符串相同的个数为1的有几种,2的有几种,n的有几种。 简单的排序加比较。用一次快排就可以了。#include <iostream> #include"string.h" #include"cstdio" #include"stdlib.h" #include"algorithm"using namespac

ShineRoyal 538

POJ 2945 Find the Clones Hash

题目大意:给出一些字符串,问其中n个一样的有多少。 思路:看discuss里各种神奇的方法啊,什么map啊,什么Trie啊。这题不是一眼Hash么。。难道是我想错了? 任意hash方法将所有字符串hash然后排序,之后统计一下相同的有多少就行了,500+MS水过。。 PS:明天就是NOIP我这么水真的好( CODE: #include #include #incl

(╯°口°)╯(┴—┴ 747

POJ2945 Find the Clones Tire树

题目大意:给出n个人的DNA序列,这些序列长度相同且不大于20,让找出重复k次的DNA的个数,其中,k=1,2,...n。 分析:这道题的处理方法很多,比较普遍的有用STL中的map的,有快排的,也有Tire树的。我试了下map的,怎么优化都是TLE,在网上找了“别人AC的代码”交也是TLE,严重怀疑这种方法的可行性啊。不过还是把代码贴出来了,可以参考一下: map代码如下(TLE版)

AC_Gibson的专栏 483

POJ 2945 - Find the Clones(字典树)

题目: http://poj.org/problem?id=2945 题意: n个长度为m的字符串,求出重复 1~n次的字符串的个数。 思路: 字典树。 AC. #include #include #include using namespace std; const int M = 4e5+5000; int wp, pi; struct node { int

Halo 561

POJ 2945 Find the Clones 水

Find the Clones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7524   Accepted: 2789 Description Doubleville, a small town in Texas, was attacked by the alien

MY Blog 1313

poj 2945 Find the Clones (map+string,hash思维)

Find the Clones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7498   Accepted: 2780 Description Doubleville, a small town in Texas, was attacked by the ali

ysCover 928

POJ2945 Find the Clones(暴力 & 字典树)

Find the Clones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7501   Accepted: 2782 Description Doubleville, a small town in Texas, was attacked by the a

GKHack's Blog 1133

POJ2945 Find the clones

传送门 Trie树的模板题。我们把每个人都存在Trie树里面,然后再每个人跑一遍即可。注意一个人走过之后要清零,否则的话会被重复计算。 #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<cmath> #in...

weixin_30919429的博客 163
上一篇: hdu 1251 统计难题
下一篇: HDU 5135 Little Zu Chongzhi's Triangles
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值