D - Sand Fortress 思路: 二分 有以下两种构造, 分别二分取个最小. 代码: #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL long long //#define mp make_pair #define pb push_back #define ls rt<<1, l, m #defi
题意:给一个字符串\(s\),有\(q\)个询问 x y l 表示问从\(x,y\)开始的长度为\(l\)的子串是否等价. 等价的定义是是否可以形成一个映射\(f\),使得把所有的第一个字符串的字符经过映射后得到恰恰是第二个字符串. 思路:首先我们看如果一个字符串等价于另一个字符串,那么它们所有字符出现位置的哈希值可以一一对应. 那么我们可以处理前缀每个字符出现的哈希值. 那么我们就可以\(O(26)\)求出每次查询了. 一一对应很简单,就是排序之后相同就行了. 原文地址:https://www
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w
题目链接:http://codeforces.com/problemset/problem/124/A Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing b
Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or - 1. To pass th