传送门 团队里的hash水题,数据小的不用hash都能过.. 也就是前缀hash,后缀hash,再比较一下就行. ——代码 #include <cstdio> #include <cstring> #define ULL unsigned long long int n, m, ans; ], s2[]; ULL ], sum1[], sum2[], bit1[], bit2[]; inline int max(int x, int y) { return x > y ? x…
题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out and returns. She is curious as to just how mu…
https://www.luogu.org/problem/show?pid=2957 题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out a…
https://www.luogu.org/problem/P2957 题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out and retur…
题目描述 Farmer John is building a brand new, NNN -story barn, with the help of his KKK cows ( 1≤N≤K≤10121 \leq N \leq K \leq 10^{12}1≤N≤K≤1012 and N≤105N \leq 10^5N≤105 ). To build it as quickly as possible, he needs your help to figure out how to alloc…
3409: [Usaco2009 Oct]Barn Echoes 牛棚回声 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 57  Solved: 47[Submit][Status][Discuss] Description 奶牛们灰常享受在牛栏中哞叫,因为她们可以听到她们哞声的回音.虽然有时候并不能完全听到完整的回音.Bessie曾经是一个出色的秘书,所以她精确地纪录了所有的哞叫声及其回声.她很好奇到底两个声音的重复部份有多长. 输入两个字符串(…
传送门 把线段都读进来然后排序,先按右端点为第一关键字从小到大排序,后按左端点为第二关键字从小到大排序. 注意不能先按左端点后按右端点排序,否则会出现大包小的情况,如下: —————— ———  — 然后直接线段树搞就行,先求区间最小值,如果大于零就更新统一减1. ——代码 #include <cstdio> #include <iostream> #include <algorithm> #define root 1, 1, n #define ls now <…
题目描述It's milking time at Farmer John's farm, but the cows have all run away! Farmer John needs to round them all up, and needs your help in the search. FJ's farm is a series of N (1 <= N <= 200,000) pastures numbered 1...N connected by N - 1 bidirec…
题目传送门 逃跑的Barn 题目描述 It's milking time at Farmer John's farm, but the cows have all run away! Farmer John needs to round them all up, and needs your help in the search. FJ's farm is a series of N (1 <= N <= 200,000) pastures numbered 1...N connected b…
题目传送门 解题思路: 二维差分的板子题.题解传送门 AC代码: #include<iostream> #include<cstdio> using namespace std; ][],ans,a[][]; int main() { scanf("%d%d",&n,&k); ;i <= n; i++) { int x,y,xx,yy; scanf("%d%d%d%d",&x,&y,&xx,&am…
题面 洛谷 题解 首先,我们知道求最长公共前缀可以用二分答案+hash来求 因为有修改操作, 考虑将整个字符串的hash值放入splay中 接着就是splay的基本操作了 Code #include<bits/stdc++.h> #define LL long long #define RG register const int N = 500010; typedef unsigned long long ull; using namespace std; inline int gi() {…
Problem: 洛谷3546 Analysis: I gave up and saw other's solution when I had nearly thought of the method ... What a pity Let's define a border of string \(s\) as a prefix \(p\) of \(s\) that \(p\) is also a suffix of \(s\), and \(p\) is not longer than h…
题目链接 #include <cstdio> #include <cstring> const int N=2e6+5,M=5e5+5,mod=2e6; const int seed[5]={31,37,131,41}; int dgr[N],fa[M]; char s[15]; namespace Hash { int cnt,val[N],pos[N]; int Get_Hash(char *s) { int x=0,l=strlen(s); for(int i=0; i<…
正解:字符串hash 解题报告: 传送门! 字符串hash是字符串匹配中很常见的一个方法,原理也很好懂,这里就不做太多阐述辣有时间放到hash笔记里面去QAQ 题意不说了挺好理解的,自带一句话概括好评 然后直接说正解QAQ 首先要想到对于读入,有三种情况 第一种,麻油有通配符的,这种最简单,直接读的时候判断一下就好 第二种,全都有通配符,显然这样的情况下,只要前后缀都是一样的,中间一定能用通配符操作一番之后变成一样的,只要判断前缀后缀就好 第三种,有的有通配符有的麻油,这种情况相对来说复杂一些,…
题目传送门 A Horrible Poem 题目描述 Bytie boy has to learn a fragment of a certain poem by heart. The poem, following the best lines of modern art, is a long string consisting of lowercase English alphabet letters only. Obviously, it sounds horrible, but that…
P3405 [USACO16DEC]Cities and States省市 题目描述 To keep his cows intellectually stimulated, Farmer John has placed a large map of the USA on the wall of his barn. Since the cows spend many hours in the barn staring at this map, they start to notice severa…
Description A crime has been comitted: a load of grain has been taken from the barn by one of FJ's cows. FJ is trying to determine which of his C (1 <= C <= 100) cows is the culprit. Fortunately, a passing satellite took an image of his farm M (1 &l…
Description A crime has been comitted: a load of grain has been taken from the barn by one of FJ's cows. FJ is trying to determine which of his C (1 <= C <= 100) cows is the culprit. Fortunately, a passing satellite took an image of his farm M (1 &l…
http://www.lydsy.com/JudgeOnline/problem.php?id=1681 太裸了.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> using namespace std; #de…
作者:戴老板:微信公众号:饭统戴老板(ID: worldofboss) 2003年5月,北京SARS疫情紧张,摩托罗拉集团总裁迈克·扎菲罗夫斯基(Mike Zafirovski)却准备不走寻常路,决定冒险访问中国. 飞机降落在弥漫着消毒水气味的首都国际机场,在穿过了无数由测温计.白口罩和铁栏杆组成的防线后,扎菲罗夫斯基抵达了东道主为他安排的钓鱼台国宾馆.第二天,他在这里代表摩托罗拉向中国捐赠了价值1180万人民币的设备物资,并对发改委主任马凯说:我对中国经济充满信心. 锦上添花易,雪中送炭难.无…
一.题目 题目描述 农夫约翰和贝西又在玩游戏.这个游戏需要很多个槽. 农夫约翰在谷仓里藏起来了N(1<=N<=20)个槽,并且他已经把其中的一些装上了食物.贝西以"在这个表里(表由贝西提供)有多少个槽里有食物?"的形式问了M(1<=M<=100)个问题. 现在,贝西想知道,哪几个槽里有食物? 这里有一个样例: (1)在第一个槽里有多少个槽里有食物?--1个 (2)在第二个和第三个槽里有多少个槽里有食物?--1个 (3)在第一个和第四个槽里有多少个槽里有食物?--…
题目描述 Farmer John and his cows are planning to leave town for a long vacation, and so FJ wants to temporarily close down his farm to save money in the meantime. The farm consists of NN barns connected with MM bidirectional paths between some pairs of…
题目戳 题目描述 Bessie is playing hide and seek (a game in which a number of players hide and a single player (the seeker) attempts to find them after which various penalties and rewards are assessed; much fun usually ensues). She is trying to figure out in…
    解法众多的一道毒瘤题? 题目描述 奶牛Bessie很喜欢闪亮亮的东西(Baling~Baling~),所以她喜欢在她的空余时间开采钻石!她现在已经收集了\(N\)颗不同大小的钻石,现在她想在谷仓的两个陈列架上摆放一些钻石. Bessie想让这些陈列架上的钻石保持相似的大小,所以她不会把两个大小相差\(K\)以上的钻石同时放在一个陈列架上(如果两颗钻石的大小差值为\(K\),那么它们可以同时放在一个陈列架上).现在给出\(K\),请你帮Bessie确定她最多一共可以放多少颗钻石在这两个陈列…
P3143 [USACO16OPEN]钻石收藏家Diamond Collector 题目描述 Bessie the cow, always a fan of shiny objects, has taken up a hobby of mining diamonds in her spare time! She has collected \(N\) diamonds (\(N \leq 50,000\) of varying sizes, and she wants to arrange so…
题目描述 The cows are so very silly about their dinner partners. They have organized themselves into three groups (conveniently numbered 1, 2, and 3) that insist upon dining together. The trouble starts when they line up at the barn to enter the feeding…
题目描述 Bessie the cow, always a fan of shiny objects, has taken up a hobby of mining diamonds in her spare time! She has collected NN diamonds (N \leq 50,000N≤50,000) of varying sizes, and she wants to arrange some of them in a pair of display cases in…
题目描述 Bessie the cow, always a fan of shiny objects, has taken up a hobby of mining diamonds in her spare time! She has collected  diamonds () of varying sizes, and she wants to arrange some of them in a pair of display cases in the barn. Since Bessie…
P3063 [USACO12DEC]牛奶的路由Milk Routing 题目背景 征求翻译.如果你能提供翻译或者题意简述,请直接发讨论,感谢你的贡献. 题目描述 Farmer John's farm has an outdated network of M pipes (1 <= M <= 500) for pumping milk from the barn to his milk storage tank. He wants to remove and update most of the…
题目描述 Farmer John and his cows are planning to leave town for a long vacation, and so FJ wants to temporarily close down his farm to save money in the meantime. The farm consists of  barns connected with  bidirectional paths between some pairs of barn…