hdu
hdu题解
Sankkl1
这个作者很懒,什么都没留下…
展开
-
2021杭电多校10 1008.Pty loves string(next数组+主席树)
题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=7084代码#include<bits/stdc++.h>using namespace std;const int N = 3e5 + 10;int q, len;char s[N];int ne[N];vector<int> g1[N], g2[N];int dfn1[N], dfn2[N], cnt1, cnt2, rr1[N], rr2[N], re[N], h原创 2021-08-25 00:41:45 · 187 阅读 · 0 评论 -
2021杭电多校9 1006.Guess the weight(线段树)
题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=7071代码#include<bits/stdc++.h>using namespace std;typedef long long ll;#define lson (k << 1)#define rson (k << 1 | 1)const int N=2e5 + 10;int n,q;int sum[N];int t[N << 3];v原创 2021-08-18 16:45:20 · 208 阅读 · 0 评论 -
2021杭电多校9 1008.Integers Have Friends 2.0(随机数)
题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=7073主要是为了学习一下mt随机的用法代码#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=2000000;const int maxn=2e6+10;const int K=30;mt19937_64 gen(time(0));int tot,prime[maxn],_,n,a原创 2021-08-18 15:28:16 · 158 阅读 · 0 评论 -
2021牛客暑期多校训练营5 1009.Array(线段树/树状数组)
题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=7020分析如果用线段树会超时,可以用树状数组,参考:https://www.luogu.com.cn/problem/solution/P4062线段树代码(超时):#include<bits/stdc++.h>using namespace std;const int N=1e6+10;vector<int>g[N];int a[N],ans[N];struct no原创 2021-08-04 15:06:54 · 325 阅读 · 0 评论 -
2021杭电多校第4场 1004.Display Substring(后缀数组)
题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=6988分析二分答案,再check答案:所有后缀的所有前缀即所有子串,利用前缀和二分找到小于等于当前答案的数量,去除重复的,即height[i],注意要取min代码#include <iostream>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;原创 2021-07-30 15:35:37 · 137 阅读 · 0 评论 -
2021杭电多校第3场 1009.Rise in Price
题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=6981分析对于每一个点,我们存下能到达它的点的所有的状态,并且这样一直推下去,每次给自己的状态排个序,a * b 大的排前面,直取前若干个(这里取100个)。代码#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<ll, ll> P;typedef vector<P原创 2021-07-28 10:34:51 · 288 阅读 · 0 评论 -
2021杭电多校第1场 1010.zoto(莫队+树状数组)
题目链接:https://acm.hdu.edu.cn/showproblem.php?pid=6959分析求出每个查询的[x0, x1]区间中所有数出现的次数,可以用莫队。然后维护一个树状数组来查询[y0, y1]区间中出现的数的种类(出现过为1,否则为0)。代码#include <bits/stdc++.h>using namespace std;#define fi first#define se second#define MP make_pair#define pb原创 2021-07-21 14:54:26 · 309 阅读 · 0 评论 -
2021杭电多校第1场 1006.Xor sum(字典树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6955分析用字典树存下每个前缀异或,每次放入建树的时候给每个点一个最新的标号。每次加入后进行查询,判断是否有数可以使其达到大于等于k的目的,每次更新最右边的符合的位置。具体看代码。代码#include <bits/stdc++.h>using namespace std;#define fi first#define se second#define MP make_pair#d原创 2021-07-20 22:20:46 · 271 阅读 · 0 评论 -
2020杭电多校第八场 1008 Hexagon
题目链接看到题目正解上面那一堆复杂的东西是不是有些迷茫,那就和我一起来找规律吧!首先我们看半径是偶数的情况然后是偶数的情况画的好累是不是很容易就看出其中的蹊跷,规律还是很明显的。因为不同人的画法不同,所以有不同情况,大体上都差不多。代码#include<bits/stdc++.h>using namespace std;int t,n;void solveji(){ for(int k=n-2;k>=1;k-=2) { int a = 4, b =原创 2020-08-13 21:26:43 · 435 阅读 · 0 评论 -
杭电多校第四场 1003 Contest of Rope Pulling(随机化+动态规划)
题意:多组输入,给定a,b两个数组,长度分别为n,m。每个元素有两个值:wi,vi,要求从两个数组中分别选出一个子数组,使得两个子数组的wi和相同,并使总的vi之和最大。数据范围:n,m<=1e3,wi<=1e3,vi<=1e9,∑(n+m)<=1e4解法参考了大佬...原创 2020-08-02 10:33:57 · 480 阅读 · 2 评论 -
2020 年百度之星·程序设计大赛 - 初赛三
1001 Discount#include<bits/stdc++.h>using namespace std;int t,n;double a,b;int main(){ scanf("%d",&t); while(t--) { double ans = 0; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%lf%lf",&a,&b); ans = max(a原创 2020-07-27 16:16:51 · 652 阅读 · 0 评论