随笔分类 - 数据结构
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1480
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1856 真的无语了,一个并查集的水题,竟然做了两个多小时,我都怀疑我自己了,还有智商么? 题意,找出最多认识人的集合 我手残了N次 ,本题1000ms,数组10000000,所以要用哈希查找 #include <i
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1232 不知道为么,这样就WA if(findx(x)!=findx(y)) merge(x,y); http://acm.hdu.edu.cn/showproblem.php?pid=1213
阅读全文
摘要:我以为像a、aa这样的输入应该是没有输出的,结果还是要输出aa。 建树的时候就是常规建树,不过查找的时候要做一些变形:对于一个单词,从第一位检查有没有单词是它的前缀,如果有的话,再去检查它的后半部分是不是一个独立的单词,要满足这两次查找才能输出。 题意:给一些单词(以字典序输入),找出那些可以分成另
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct Node { struct Node *next[10]; int flag; } Node,*Tree; int flag1; void Creat(Tree &T) { T=(Node *)malloc(sizeof(...
阅读全文
摘要:这题看是否 这题能A是侥幸,解决的办法是先存一下输入的字符串,进行排序。 Problem Description An encoding of a set of symbols is said to be immediately decodable if no code for one symbol
阅读全文
摘要:这题就是一个字典树的模板题 统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others) Total Submission(s): 16997 Accepted Submission(s)
阅读全文
摘要:大意:输入几个字符串,然后再输入几个字符串,看第一次输入的字符串有多少没有在后面的字符串中出现(后输入的字符串不一定出现在之前的字符串中) #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct Node {
阅读全文
摘要:一改时间以后WA了,我就知道这题是考字典树,可惜代码怎么也不会敲了,郁闷。 #include <stdio.h>#include <string.h>#include <stdlib.h>typedef struct Node{ int flag; struct Node *next[26]; }N
阅读全文
摘要:1.打表 打表,是一个信息学专用术语,意指对某种找规律等题目,直接输出答案。这种算法也在对某种题目没有最优解法时,用来得到分数的一种策略。 打表一般分为两步:找到答案与输出答案。 找到答案的方式 一、通过找规律,找出对于每个输入数据n,f[n]的最终结果。 常见题目有费波纳契数列等; 二、通过暴力搜
阅读全文
摘要:A(Phone Number) 1.字典树 2.暴力 #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> using namespace std; in
阅读全文
摘要:题意: 有一个公司由于某个病毒使公司赢亏数据丢失,但该公司每月的 赢亏是一个定数,要么一个月赢利s,要么一月亏d。现在ACM只知道该公司每五个月有一个赢亏报表,而且每次报表赢利情况都为亏。在一年中这样的报表总共有8次(1到5,2到6,…,8到12),现在要编一个程序确定当赢s和亏d给出,并满足每张报
阅读全文
摘要:主要是思维,dis[s][t]数组的作用
阅读全文
摘要:[题目大意]:给定一个字符串,求到哪一位时的字串是前几位循环组成的,并求出循环次数。 思路:求每个前缀的最小循环周:从i到n枚举len,如果len%(len-next[len])==0,则这个前缀是由循环节组成的,且循环次数为len/(len-next[len])//len为当前i的值,next[l
阅读全文
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h>char a[1000001];int next[1000001];int l;void Getnext(){ int j=-1; int i=0; next[0]=-1;//忘写了,死循
阅读全文
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h>char a[1000001],b[1000001];int next[1000001];int l,l2;void Getnext(){ int i=0; int j=-1; next[
阅读全文
摘要:#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>using namespace std;int n,m;int bin[50001];int findx(int x){ int r=x; while
阅读全文
摘要:http://poj.org/problem?id=1611 Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a g
阅读全文
摘要:sort: 一、对int类型数组排序 int a[100]; int cmp ( int a , int b ) //不必强制转换 { return a < b;//升序排列。 } sort (a(数组名) , a+100(数组最后一个元素), cmp); 头文件 #include<algorith
阅读全文
浙公网安备 33010602011771号