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

线性代数——(期末突击)行列式(上)-行列式计算、行列式的性质 简单解释一下:4213原本的顺序应为1234,对于‘4’而言,‘2’、‘1’、‘3’都应该排在它的前面,所以此处记逆序数为3;对于‘2’而言,‘1’应该排在它的前面,而‘3’排在它之后 是合理的,所以此处只有一个逆序数;最后看‘1’,其后面的‘3’排在后面显然也是合理的,故而4213的逆序数为4.一般我们使用这个性质来计算四阶行列式,也就是将其变换成三角行列式,再计算对角线的值;以主对角线为分界线的就为正三角,反之则为反三角行列式。若行列式某一行(列)为0,则该行列式=0.将和的那一行分开,其余行。 阅读详情

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]);
	}
}


VSS shielding线可以floating吗? shielding vss不打孔,就相当于dummy metal,如果周围有其他干扰线,他们影响了这段dummy metal,这段dummy metal仍然会对目标线产生干扰,bug的是,工具知道这段dummy是vss,那么计算寄生的时候仍然把它当vss,就有可能噪声没有完全消除,而用户又看不见。而真正接地的线,相当于一直是0,就不会对目标线产生干扰,一般加shield是在route之前,这时候shield能尽量覆盖目标线,等到绕线后再加就会出现shield只覆盖到一部分目标线的情况。 阅读详情

相关推荐

【GPT】Coze使用开放平台接口-【7】Dify 比较篇

coze 用于社交,dify 用来内部构建。抛开工作流,机器人,工具,coze 最大的区别在于可以直接发布到社交媒体上。所以,coze 对操作体验上也花了不少功夫,而 dify 就专注在帮助使用者打磨工作流。coze 各个大模块之前可以联动的机制也比较多,所以侧重点各不相同。

非晓为骁的博客 7612

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

【技术解析】Point-NeRF:如何通过点云优化加速神经辐射场渲染

本文深入解析了Point-NeRF技术,它通过引入3D点云作为几何先验,有效解决了传统神经辐射场渲染速度慢的痛点。该方法利用神经点云构建局部辐射场,结合点剪枝与生长策略进行动态优化,在保证高渲染质量的同时,实现了高达30倍的训练加速,为高效3D场景重建提供了新范式。

weixin_29159127的博客 266

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蜗牛之家 1219

IEEE802.11bf: WLAN Sensing Standard

下表为IEEE802.11bf 定义的使用情境 (Use Cases)

qinsd19的博客 1054

本地部署静态网站托管平台 Netlify 并实现外部访问(Windows 版本)

Netlify 是一款基于云计算的网站部署和托管平台,专为开发者提供便捷的静态网站和 Jamstack 应用部署服务。它的能力在于将网站构建、部署、托管以及持续集成等流程高度集成,简化了开发和运维的复杂程度。用户无需关心服务器的配置、维护等工作。本文将详细介绍如何在本地安装 Netlify 以及结合路由侠内网穿透实现外网访问 Netlify。

lyxnwct的博客 523

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

Vue和Vue-Element-Admin(六):集成中的CORS(跨域资源共享)问题

在vue-element-admin登录集成时候碰到跨域资源共享问题,CORS(Cross-origin resource sharing)是浏览器的技术规范,浏览器可以发起跨域请求但Javascript脚本不能,传统的ajax只能获取在同域名下的资源,但Html5允许ajax发起跨域请求,解决方案有:JSONP、Flash、IFrame、CORS。 一、CORS(跨域资源共享)问题 针对vue-element-admin的登录模块的后端接口完成后,前端调用时候出现报错,因为前端的端口是9527而后.

叶子叶来 9612

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

让 ABAP 程序天生可翻译:Text Symbols 与 Text Pool 从入门到工程化落地

ABAP 国际化实践:Text Symbols 的工程价值与落地方法 摘要: 本文系统阐述了 ABAP 开发中 Text Symbols 的核心价值与实践方法。通过解耦程序逻辑与语言文本,Text Symbols 实现了代码国际化,避免了硬编码带来的维护难题。文章详细介绍了 Text Pool 结构、两种引用方式(独立引用 TEXT-001 和附着式 '(001)'),以及 SE38 和 SE63 的翻译流程。特别强调最大长度预留、术语统一等工程实践,并提供了 READ TEXTPOOL 自动化检查方案。最

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 233

24、无人机能耗模型与上下文质量管理的研究

本文系统介绍了无人机能耗模型与上下文质量管理的研究进展。详细阐述了Dorling、Stolaroff、Kirchstein和Tseng等经典能耗模型的原理及特点,并基于LSTM架构构建了数据驱动的能耗预测模型,实验表明其预测精度显著优于传统模型。此外,还探讨了物联网环境中的上下文质量管理问题,引入了conQeng框架,以提升上下文选择、测量和验证的效率与可靠性。研究为无人机能耗优化和物联网上下文管理提供了理论支持和技术方案。

palm99的专栏 344

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

开源项目-智能算法中台管理系统

智能算法中台管理系统,系统主要有样本中心,算法中心,模型中心等模块

u010479989的博客 2996

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

算法之道 742

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

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

efm32 入门.pdf

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

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

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

xdlove 963

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

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

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的博客 237

POJ2945字母树trie的使用

独立地写完了字母树trie处理重复字串的问题,感觉还是挺好的,发篇博客纪念一下。#include "stdio.h"#include "stdlib.h"#include "string.h"int n,m;typedef struct trie{ int num; int deep; struct trie *next

qiuzhenguang的专栏 1787

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的专栏 1175

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万+

找出克隆人

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

Formiko的博客 951

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;&#...

花海 210

poj 2945

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

sdjzujxc的专栏 913

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
上一篇: 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、付费专栏及课程。

余额充值