博文

目前显示的是标签为“字符串”的博文

字符串hash

课件: 字符串hash blue   字符串 HASH   字典匹配   给定一篇文章和一个词典。   询问文章中出现了多少个词典中有的单词。   这题一万种做法……   HASH IT!   莫名其妙   等比数列 HASH   等比数列 HASH   等比数列hash是什么样子呢?   hash[i]=hash[i-1]*233+str[i]   然后hash[n]就表示字符串的hash结果。   用 unsigned long long 来存hash结果。   不需要取模,因为会自然溢出。   或者用别的什么数据结构存。   扩展   这么神,你怕不怕   字符串匹配   字符串匹配   TRIE   如何用Trie来做这个事情?   优化路径。   HASH IT!   COGS [月考]   简单 HASH   月考   有人在月考的时候作弊。学校广播把这个人D了一番。   这个人有一些狐朋狗友。他特别不希望这些小伙伴听到广播。   给定听到广播的人的名单和他的朋友的名单,输出哪些人听到   了广播。   >>>题目来源:COGS   暴力排序   基数排序   TRIE   HASH IT!   永恒的话题……   避免冲突   冲突   避免冲突   考虑如何避免冲突。...

CF5C Longest Regular Bracket Sequence

题目来源 CodeForces 5C 评测方式 RemoteJudge 难度 提高+/省选- 题意翻译 给出一个括号序列,求出最长合法子串和它的数量。 合法的定义:这个序列中左右括号匹配 题目描述 This is yet another problem dealing with regular bracket sequences. We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we can get a correct mathematical expression. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not. You are given a string of «(» and «)» characters. You are to find its longest substring that is a regular bracket sequence. You are to find the number of such substrings as well. 输入格式 The first line of the input file contains a non-empty string, consisting of «(» and «)» characters. Its length does not exceed  10^{6} 1 0 6  . 输出格式 Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1". 输入输出样例 输入 #...