ICode9

精准搜索请尝试: 精确搜索
  • P5043 【模板】树同构([BJOI2015]树的同构)2019-08-01 22:04:27

    P5043 【模板】树同构([BJOI2015]树的同构) 思路:树hash,先找树重心,重心最多两个,然后从以重心为根求出树的hash值,放进map里。 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1 y11 #define fi

  • 【POI2010】ANT-Antisymmetry2019-07-31 23:02:41

    题面 https://www.luogu.org/problem/P3501 题解 #include<cstdio>#include<iostream>#include<cstring>#define ri register int#define N 500050#define uLL unsigned long longusing namespace std;int n;char s[N];const uLL p=107;uLL sum1[N],sum2[N];uL

  • 【JSOI2016】独特的树叶2019-07-31 23:00:24

    题面 https://loj.ac/problem/2072 题解 #include<cstdio>#include<iostream>#include<cstring>#include<vector>#include<map>#include<set>#include<algorithm>#define N 100500#define uLL unsigned long long#define ri register

  • 字符串hash2019-07-26 20:03:20

    #include<bits/stdc++.h>#define ll long long#define ull unsigned long longconst int inf = 0x3f3f3f3f;const int N = 4e5+7;const ll mod = 998244353;using namespace std;ull hash1=13331;ull ha[N],pp[N];ull getha(int l,int r){ if(l==0) return ha[r];

  • 【洛谷3822】[NOI2017] 整数(线段树压位).md2019-06-09 14:01:51

    题目: 洛谷 3822 分析: 直接按题意模拟,完了。 将每次加 / 减拆成不超过 \(32\) 个对单独一位的加 / 减。 考虑给一个二进制位(下称「当前位」)加 \(1\) 时,如果这一位本来就是 \(0\) ,那么直接变成 \(1\) 。否则要考虑进位:向左(以后默认从右向左为低位至高位,与书写顺序相同)找到第一个为 \(

  • 字符串哈希和哈希表2019-05-06 11:54:37

    字符串哈希 #include<iostream> #include<cstdio> #include<cstring> #include<set> using namespace std; typedef unsigned long long ull; int n; char str[1510]; set<ull> S; ull str_hash(char str[]) //2^64自然溢出 {

  • A - Subpalindromes URAL - 1989 (线段树)2019-04-26 14:52:00

    一个字符串可以表示为: ,故当哈希冲突率低的时候,可以将字符串唯一表示为一个数字,本题线段树就是维护区间和。 #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<iostream> #include<queue> #include<stack> using namespace std; const in

  • hdu4622(hash解法)2019-04-24 22:41:03

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4622 Now you are back,and have a task to do:Given you a string s consist of lower-case English letters only,denote f(s) as the number of distinct sub-string of s.And you have some query,each time you should c

  • [数]数学系列预习->补水题ver.2019-04-11 20:52:33

    ---恢复内容开始--- 话说要学反演了,contest一题都搞不定,整理题目暂且搁置,数学笨蛋来学一下数学_(:з」∠)_ ---恢复内容结束--- 是的,预习看了半天教学,没有整理,做题又都不会,我能怎么办呢_(:з」∠)_我只能补题了呀   HDU-3903  结论题,易证   首先由余弦定理,abc都是有理数所以co

  • POJ 2774 Long Long Message (二分 + Hash 求最长公共子串)题解2019-04-06 20:49:06

    题意:求最长公共子串 思路:把两个串Hash,然后我们把短的作为LCS的最大可能值,然后二分长度,每次判断这样二分可不可以。判断时,先拿出第一个母串所有len长的子串,排序,然后枚举第二个母串len长度字串,二分查找在第一个母串的子串中存不存在。 代码: #include<cmath>#include<stack>#include<

  • bzoj4892 [TJOI2017]DNA2019-04-06 12:50:10

    \(\verb|bzoj4892 [TJOI2017]DNA|\) 给定一个匹配串和一个模式串,求模式串有多少个连续子串能够修改不超过 \(3\) 个字符变成匹配串 \(len\leq10^5\) hash 枚举子串左端点,hash 求 lcp 枚举断点,接着跳过断点,记作一次修改,最多修改 \(3\) 次。特判修改 \(3\) 次后剩余部分是否相等。

  • 给出前序和后序,计算可能的树的种类2019-03-11 18:53:24

    第一注意整数溢出的情况 第二,递归函数的含义要非常的明确,这样才能真正明白它的含义,以及确定出边界条件 第三,如果一个指令有可能不执行,那么要放到循环体的里面去 下面是代码 #include<iostream>#include<string>using namespace std;typedef unsigned __int64 ULL;ULL cnt = 1;stri

  • bzoj5407: girls2019-02-24 21:01:06

    题目描述: 大皮出行,妹子成群,似乎这种事早已经司空见惯了。 大皮最终还是厌倦了这样的⽣活,懂得了节制,他希望每次恰好只有三个妹子陪他。  大皮有 $n$个妹子,编号为$0$到$n-1$ ,大皮需要次从$n$个中选出三个来愉悦身心。 那么问题来了,有许多妹子为了得到大皮的欢心,产生了冲突,这样的冲突

  • 牛客练习赛1 矩阵 字符串二维hash+二分2019-02-24 17:37:54

    题目 https://ac.nowcoder.com/acm/contest/2?&headNav=www#question 解析 我们对矩阵进行二维hash,所以每个子矩阵都有一个额hash值,二分答案然后O(n^2) check 枚举矩阵终点,记录每个hash值与有两个一样的就true AC代码 #include<bits/stdc++.h> using namespace std; typedef unsig

  • bzoj 4811 由乃的OJ2019-02-21 08:49:04

    bzoj 4811 由乃的OJ 考虑树链剖分. 树剖后用一颗线段树维护一段连续区间,类似于一个函数,各位上进入 \(0/1\) ,输出的数字分别是什么.注意到最多只有 \(64\) 位,可以用一个 \(unsigned\ long\ long\) 的大数状压表示,合并两段区间时推导一下可以做到 \(O(1)\) . 注意 \(3 种\)位运

  • Codeforces 551D - GukiZ and Binary Operations 矩阵快速幂2019-02-08 16:52:48

    GukiZ and Binary Operations 显然我们要拆位, 因为每位都独立, 然后问题就变成能用dp求的东西,然后用矩阵快速幂优化一下。 注意mod为1的情况。 #include<bits/stdc++.h>#define LL long long#define fi first#define se second#define mk make_pair#define PLL pair<LL, LL>#define

  • 『一本通』哈希和哈希表2019-02-06 18:01:34

    Oulipo 1 #include<bits/stdc++.h> 2 #define N 1000000+5 3 using namespace std; 4 typedef unsigned long long ULL; 5 const int b=55; 6 ULL n,m,s,ans,p[N],sum[N]; 7 char s1[N],s2[N]; 8 9 int main() { 10 scanf("%s",s1+1),scanf(&q

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有