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

【100%通过率】华为od机试C卷【特殊的加密算法】Python 实现 有一种特殊的加密算法,明文为一段数字串,经过密码本查找转换,生成另一段密文数字串。规则如下1.明文为一段数字串由0-9组成2.密码本为数字0-9组成的二维数组3.需要按明文串的数字顺序在密码本里找到同样的数字串,密码本里的数字串是由相邻的单元格数字组成,上下和左右是相邻的,注意:对角线不相邻,同一个单元格的数字不能重复使用。 阅读详情

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 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.

Source


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

题目大意:给出一些基因片段,计算相同基因片段的数目,求这些数目出现的次数。

解题思路:map+hash水题,这题我用字典树也写过,参见字典树分类。

代码如下:

#include <cstdio>
#include <iostream>
#include <cstring>
#include <map>
#include <string>
using namespace std;
map <string,int>mp;
const int maxn=20005;
int ans[maxn];
int main(void)
{
	//freopen("in.txt","r",stdin);
	int n,m;
	while(scanf("%d%d",&n,&m)!=EOF&&(n+m))
	{
		int cnt=0;
		memset(ans,0,sizeof(ans));
		for(int i=0;i<=n;i++)
			mp.clear();
		for(int i=0;i<n;i++)
		{
			char s[25];
			scanf("%s",s);
			string a=s;
			ans[mp[a]]--;     //相同基因个数出现次数改变了,原来的个数出现次数减1,改变后的加1
			mp[a]++;
			ans[mp[a]]++;
		}
		for(int i=1;i<=n;i++)
			printf("%d\n",ans[i]);
	}
}


2、集中式MIMO雷达研究进展:正交波形设计与信号处理 集中式多输入多输出(Multiple Input Multiple Output,MIMO)雷达通常利用正交波形增加发射波形 自由度,采用数字阵列拓展空间收发自由度,使得雷达接收机的天线孔径获得明显扩展,最终带来空间分辨率、 测角精确度、杂波抑制能力等大幅度提升。但是,这些性能提升的前提是发射波形具有正交特性。事实上,在 实际应用中,在不牺牲时域/频域资源情况下,受限于时宽带宽积,无法获得完全正交的波形集合,从而限制了 MIMO雷达系统性能。本文对集中式MIMO雷达正交波形复用的技术原理进行了系统回顾,分别 阅读详情

相关推荐

X猫免费小说安卓逆向分析

七猫免费小说安卓逆向分析 难度(♥♥) 文章目录七猫免费小说安卓逆向分析 难度(♥♥)1. 查壳2. 抓包分析3. sign1. Frida-rpc2. Native函数分析快3点了. 睡觉~ 白天再继续写! 1. 查壳 我这边使用的是ApkTool, 拖进去显示未加壳。 2. 抓包分析 POST https://xiaoshuo.wtzw.com/api/v1/login/index HTTP/1.1 net-env: 1 channel: qm-cbcpa056_wm is-white: 0 platf

Qiled的博客 4383

poj_2945 Find the Clones (Trie树 内存分配)

【题目描述】 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)

Je vole 585

cadence数模混合仿真反标sdf

数模混合IC设计时经常要调用一些Verilog模块(最简单的例如SPI接口),在前仿时一般直接用rtl代码来仿真,但是后仿时要关注因寄生带来的延迟,避免这些额外的延迟导致时序错误,因此不能简单地采用RTL来仿真。 一般有两种办法:1是采用由RTL综合得到的门级电路来仿真,这种方法比较简单,但是缺点是规模较大,而且只包括门延迟不包括因版图导致的线延迟;如果想要仿真更精细,就要对该这部分门电路提取寄生参数; 另一种方式是利用sdf文件(standard delay format)来进行仿真。后端工具在布局布

长河柱天的博客 7286

Find the Clones(字典树)

链接:http://poj.org/problem?id=2945 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

AI蜗牛之家 1223

ComfyUI-controlnet控制出图

提供加载预处理器节点。

Bu2n的博客 5507

从零开始使用matlab实现EKF-SLAM算法(含完整代码)

扩展卡尔曼滤波器同步定位与建图 (EKF-SLAM) 算法建立在 EKF 的基础上,集成了 EKF 的功能,可解决机器人技术中最具挑战性的问题之一:同时定位与建图 (SLAM)。 EKF-SLAM采用EKF方法来同时估计机器人的状态和周围环境的布局,而无需事先了解位置。 这种双重功能对于在未知环境中运行的自主系统至关重要,使它们能够在绘制区域地图时有效导航。 EKF-SLAM 算法一直是自动驾驶车辆和机器人系统开发的基石,为处理现实世界环境中固有的不确定性提供了一个强大的框架。

mjmmm的博客 6649

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

究竟什么是虚拟同步机???虚拟同步机巨简单理解

同步发电机定子铁芯的内圆均匀分布着定子槽,槽内按一定规律嵌放着对称的三相绕组U1-U2、V1-V2、W1-W2,如图1所示。工作原理转子铁芯上装有制成一定形状的成对磁极,磁极上绕有励磁绕组。励磁绕组上通直流电时,会在电机的气隙中形成极性相间的分布磁场,称为励磁磁场。当原动机拖动转子以恒定速度旋转时,励磁磁场随转轴一起旋转并顺次切割定子各相绕组。定子电枢绕组中将会感应出大小和方向周期性变化的三相对称正弦感应电动势。各相电动势大小相等,相位各差120°。

weixin_53126442的博客 2621

2945 Find the Clones //trie

Find the ClonesTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 5151 Accepted: 1898<br />DescriptionDoubleville, 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

hqd_acm的专栏 1107

实战:RK3568 Android14 点亮 LVDS 屏幕

4组数据 (D0~D3) + 1组时钟 (CLK)。最大支持 1280x800 @ 60Hz。8组数据 (Even03, Odd03) + 2组时钟。支持 1080P 及以上。/ {/* 背光与电源 *//** 关键配置:数据格式映射* 可选值: "jeida-18", "jeida-24", "vesa-24"* 6位屏选 xx-18, 8位屏选 xx-24* 颜色不对(偏色/底片效果)就换 VESA <-> JEIDA*/

qq_33427070的博客 1175

使用Python实现深度学习模型:智能极端天气事件预测

在本项目中,我们成功利用Python和Keras库构建了一个基于LSTM的极端天气预测模型。通过时间序列数据,模型能够识别天气趋势并预测未来的极端天气事件。尽管这是一个简化的示例,但它为实际应用中如何利用深度学习进行天气预测提供了一个很好的基础。随着更精确的数据和更多的特征信息,类似的模型可以进一步扩展到其他极端事件预测上,如风暴预警、气象灾害评估等。

Echo_Wish 743

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

基于STM32开发板的USB MIDI键盘实现

在本文中,我们介绍了如何使用STM32开发板和相应的软件工具来实现USB MIDI键盘。通过配置STM32CubeMX和编写相应的源代码,我们能够将STM32开发板转换为一个功能齐全的USB MIDI设备。我们将使用STM32开发板和相应的软件工具来实现这一功能,并提供相应的源代码供参考。此时,您应该可以使用STM32开发板作为USB MIDI键盘,并在按键按下时听到相应的音符。在STM32CubeMX中,选择适当的STM32型号,并启动一个新的项目。然后,将生成的可执行文件烧录到STM32开发板中。

2301_79326616的博客 1593

HHTC_学校集训编程题目(7)(个人赛_1)

HHTC_学校集训编程题目(7)(个人赛_1)A - Choose Your Words CarefullyB - Find the ClonesF - AlaskaG - SubstringsH - decimal systemI - Secret A - Choose Your Words Carefully Let’s face it, most students who do a goo...

A_dmin的博客 588

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

POJ 2945  Find the Clones

Find the Clones Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5467 Accepted: 2030 Description Doubleville, a small town in Texas, was attacked by the aliens. They have abduc

算法之道 743

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

poj 2945 Find the Clones

https://vjudge.net/problem/POJ-2945 题意: 给出n个长度相同的DNA序列,如果一个DNA序列出现过两次,那么就有说明它被复制了一次。问被复制0次,1次,2次……n-1次的DNA序列分别有多少个。 思路: 可以利用字典树的方法做,用map目测会超时。因为一个字符串是它自己本身的假前缀,所以把每一个字符串的前缀数量-1,就是它被复制的数目。这题学到了一个技巧...

weixin_30897233的博客 158

Find the Clones(字典树之哈希功能)

萌萌哒的链接:http://poj.org/problem?id=2945 题目的意思就是找每一个字符串出现的次数,输出出现1-n次的字符串的个数. 字典树的哈希应用.index记录相同字符串出现的次数,最后dfs查找. 因为题目中只有4个字母,所以dfs总的时间复杂度 为4*字典树的总结点个数. 字典树用链表写挺方便的,就是内存花销太大,比如这道题目如果把内存开成26,就

xdlove 964

poj 2945

accept #include<iostream> #include<cstdlib> #include<string> #include<algorithm> using namespace std; char ss[20005][25]; int num[20005]; int n,m; int cmp(cons...

weixin_30550271的博客 167

POJ2945链式字典树解决方案

POJ2945链式字典树解决方案 首先,我们的思路是用链式的字典树结构,解决POJ2945这道题 题意是,统计所有的字符串出现的次数,并依次输出各个次数的数量 例如: input 9 6 AAAAAA ACACAC GTTTTG ACACAC GTTTTG ACACAC ACACAC TCCCCC TCCCCC out 1 2 0 1 0 0 0 0 0 遇到的一些小麻烦 : 之前提交poj爆内存...

KhazixW2的博客 238

poj 2945

题意:给出若干个字符串,问你i个相同字符串的个数,然后输出第i行代表有i个相同字符串的个数。 思路:此题是来自修改别人TLE的代码,此题最大是20000,用两层for肯定超时,所以就先排了个序,然后以个for遍历寻找记录即可。 #include #include #include #include using namespace std; struct node { ch

sdjzujxc的专栏 913

poj 2945 Find the Clones trie树的简单应用

题意: 给n个长m的字符串,统计他们的出现频率,输出出现1次的有几种,出现2次的有几种...出现n次的有几种。n 分析: 也可以用排序,map水的,但还是写个trie树也不麻烦,trie树我就得就是针对字符串的hash表,效率如果数据大点是比暴力解法高很多的,另外写的时候不小心把index定义成char,n 代码: //poj 2945 //sep9 #include using na

sepNINE的专栏 761

poj2945

前阵子用Trie树过了poj2945,当然题目本身比较水,但数据量应该还是比较大的。限制时间为5秒。 4548K && 547MS Trie树解法: #include #include #include using namespace std; int const childnum = 4; const int map[] = { 0, -1, 1, -1, -1, -1, 2

architect19的专栏 1176

c++ 中map 的find 用法

用find函数来定位数据出现位置,它返回的一个迭代器,当数据出现时,它返回数据所在位置的迭代器,如果map中没有要查找的数据,它返回的迭代器等于end函数返回的迭代器,程序说明#include &lt;map&gt;#include &lt;string&gt;#include &lt;iostream&gt;Using namespace std;Int main(){       Map&lt...

gaosaixing的博客 21万+

poj2945 字典树题目

判断相同字符的个数#include #include #define max 510010 struct node { int len; int ju; struct node *next[26]; } Node,Root[max]; int sum=0; int num[max]; void BuildTree(char *word) { node *root=&

wahaha1_的专栏 1001

找出克隆人

找出克隆人 Time Limit:50000MS  Memory Limit:65536K Case Time Limit:5000MS Description 达波维尔,田纳西洲的一个小镇,遭到了外星人的进攻。外星人绑架了一些当地的居民并把他们带到了外星飞船上。在飞船上,外星人通过克隆技术复制了其中一些居民,然后把这些克隆人连通被绑架的居民一起放回到了达波维尔。现在的情况是,有可能有6个

Formiko的博客 952

POJ 2945 Trie

&#13; 链接:&#13; http://poj.org/problem?id=2945&#13; 题解:&#13; 给你n个字符串,统计出现1~n次的字符串各有多少个&#13; 题解:&#13; 这道题最快的做法应该就是字典树了吧,边插入边更新答案就行了&#13; 代码:&#13; &#13; 31 int cnt[MAXN];&#13; 32 int pi = 1;&#...

花海 212
上一篇: CSU 1601 War (并查集)
下一篇: hdu 1233 还是畅通工程 (克鲁斯卡尔裸题)
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址