原题链接:https://nanti.jisuanke.com/t/31450 附上队友代码:(感谢队友带飞) #include <bits/stdc++.h> using namespace std; #define ll long long #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define DOR(i,a,b) for(int i=(a);i>=(b);--i) const int maxN=2e5+5,inf=0x3f3…
[链接] 我是链接,点我呀:) [题意] [题解] 每个单词的前缀都不同. 不能更明示了... 裸的字典树. 模拟一下.输出一下就ojbk了. [代码] #include <bits/stdc++.h> #define LL long long #define rep1(i,a,b) for (int i = a;i <= b;i++) #define rep2(i,a,b) for (int i = a;i >= b;i--) #define all(x) x.begin(),x…
题意: 二分图 有k条边,我们去选择其中的几条 每选中一条那么此条边的u 和 v的度数就+1,最后使得所有点的度数都在[l, r]这个区间内 , 这就相当于 边流入1,流出1,最后使流量平衡 解析: 这是一个无源汇有上下界可行流 先添加源点和汇点 超级源超级汇  跑遍dinic板子 就好了...看了一发蔡队的代码,学到了好多新知识(逃)... #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a)) #define r…
题目链接: https://nanti.jisuanke.com/t/31452 AC代码(看到不好推的定理就先打表!!!!): #include<bits/stdc++.h> using namespace std; # define maxn 40000+100 int a[maxn]; int b[maxn]; int ans=0; char s[1000]; int c[maxn]; int ti=0; void f() { memset(c,0,sizeof(c)); memset(…
求第k短路 模板题 套模板即可 #include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <queue> using namespace std; ; ; struct State{ int f; // f=g+dis dis表示当前点到终点的最短路径,即之前的预处理 int g; //g表示到当前点的路径长度 int u; bool op…
https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集组成的数字是个素数或1. 分析 打表发现满足要求的数字很少.实际上因为一个数不能出现两次,而偶数不能存在.这样最后只有20个数符合要求. #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ; ] = {,,,…
Supreme Number A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying two smaller natural numbers. Now lets define a number N as the supreme number if and only if each number made up of an non-empty subse…
Made In Heaven One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. However, Pucci the father somehow knows it and wants to stop her. There are N spots in the jail and MM roads connecting some of the spots. JOJO finds…
131072K   One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. However, Pucci the father somehow knows it and wants to stop her. There are NN spots in the jail and MM roads connecting some of the spots. JOJO finds tha…
J. Ka Chang Given a rooted tree ( the root is node 11 ) of NN nodes. Initially, each node has zero point. Then, you need to handle QQ operations. There're two types: 1\ L\ X1 L X: Increase points by XX of all nodes whose depth equals LL ( the depth o…
A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying two smaller natural numbers. Now lets define a number NN as the supreme number if and only if each number made up of an non-empty subsequence of all…
"Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a bipartite graph is a fantastic graph. He has two fantastic numbers, and he wants to let all the degrees to between the two boundaries. You can pick up sev…
ACM-ICPC 2018 南京赛区网络预赛 E题 题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest with n (0 < n \le 20)n(0<n≤20) problems. And he knows the answer of all of these problems. However, he can submit ii-th problem if and only if he has s…
Jessie and Justin want to participate in e-sports. E-sports contain many games, but they don't know which one to choose, so they use a way to make decisions. They have several boxes of candies, and there are ii candies in the i^{th}ith box, each cand…
There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of the i^{th}ith kind of ship is 2^{C[i]} - 12C[i]−1. How many different schemes there are if you want to use thes…
God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells him that some sequence of eating will make them poisonous. Every hour, God Water will eat one kind of food among meat, fish and chocolate. If there are 33 …
Bob is a sorcerer. He lives in a cuboid room which has a length of AA, a width of BB and a height of CC, so we represent it as AA * BB * CC. One day, he finds that his room is filled with unknown dark energy. Bob wants to neutralize all the dark ener…
Now you have a string consists of uppercase letters, two integers AA and BB. We call a substring wonderful substring when the times it appears in that string is between AA and BB (A \le times \le BA≤times≤B). Can you calculate the number of wonderful…
There are NN children in kindergarten. Miss Li bought them NN candies. To make the process more interesting, Miss Li comes up with the rule: All the children line up according to their student number (1...N)(1...N), and each time a child is invited,…
A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reached adulthood and decided to use his knowledge to esca…
https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. 贪心做法: 考虑两个集合A和B,A为L<=d[i]<=R,B为d[i]>R 枚举每个边 1.如果u和v都在B集合,直接删掉2.如果u和v都在A集合,无所谓3.如果u在B,v在A,并且v可删边即d[v]>L4.如果u在A,v在B,并且u可删边即d[u]>L 最后枚举N+M个点判断是…
https://nanti.jisuanke.com/t/31443 题意 给出一个表达式,求最小值和最大值. 表达式中的运算符只有'+'.'-'.'*'.'d',xdy 表示一个 y 面的骰子 roll x 次的和,其中x>=0,y>=1,实际上它的最小值就是x,小于0时要强制变为0,最大值就是 x*y ,题目给的表达式保证运算都是合法的,并且中间过程和结果都是int范围内. 分析 表达式求值,多了一个d运算,维护最大最小值,在乘法的时候取所有极值的情况. 中序表达式->后序表达式(左…
https://nanti.jisuanke.com/t/31448 题意 已知a序列,给你一个n和m求小于n与m互质的数作为a序列的下标的和 分析 打表发现ai=i*(i+1). 易得前n项和为 Sn=n*(n+1)(2*n+1)/6+n*(n+1)/2;我们直接求与m互质的数较难,所以我们可以换个思路,求与 m不互质的数,那么与m不互质的数,是取m的素因子的乘积(因为根据唯一分解定理,任意个数都可看作的素数积),那么我们将m分解质因数,通过容斥定理,就可以得道与m不互质的数,总和sum减去这…
https://nanti.jisuanke.com/t/31450 题意 给出一个映射(左为ascll值),然后给出一个16进制的数,要求先将16进制转化为2进制然后每9位判断,若前8位有奇数个1且第9位为0则这个子串取,若前8位有偶数个1且第9 位为1也取.取出的串在映射中进行查找,输出对应ascll值的字符 分析 用map直接模拟,细节需要注意. #include <bits/stdc++.h> using namespace std; #define ms(a, b) memset(a…
https://nanti.jisuanke.com/t/31445 题意 能否在t时间内把第k短路走完. 分析 A*算法板子. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <algorithm> #include <cmath> #include <cti…
垃圾题,题目巨TM长...这题题意就是说给你一个16进制串,让你把每一位转成长度为4的2进制数,并把这些数连接起来,连接完成后,进行奇偶校验,把字符串切割成每个长度为9的字符串,然后计算前8位的 1的个数,,最后一位是校验位,如果1的个数为奇数 那么校验位应该是1,如果1的个数为偶数,那么校验位应该是0,如果满足,就保留验证的8位去掉校验位,否则去掉整个:然后给了M个字符串对应的ASCll,把验证位置留下来的东西,进行和字符串匹配,然后输出N个对应ASCll的字符??? 这题意很绕啊...不过纯…
这题很好啊,好在我没做出来...大概分析了一下,题目大概意思就是求 问所有满足1<=i<=n且i与m互素的ai之和 最开始我们队的做法是类似线性筛的方法去筛所有数,把数筛出来后剩下数即可,但是这样的是时间复杂度十分大,我们需要遍历每个质因 的倍数,这样最坏的复杂度是很大的1e8,因为我们需要把i的倍数筛到1e8,这样肯定不行,那么想想其他办法 我们想到了容斥-----(赛后想到的) 我们可以推处一个公式ai=i*i+i; 那么ai的前n项和Tn=n*(n+1)*(2*n+1)/6+n*(n+1…
题目链接:https://nanti.jisuanke.com/t/31451 题意: 给你一颗树,树上各点有初始权值,你有两种操作: 1. 给树中深度为l的点全部+x,(根节点为1,深度为0) 2.求出以x为根的子树权值和 思路: 因为第一个操作是对一整层的树节点+x,那么我们可以很容易的标记每一层一共加了多少权值,那么子树增加的就是以x为根到叶子节点每一层增加的值之和乘以这颗子树当前层的节点数,我们可以用二分快速找到每一层的节点个数,但是我们还是会发现,这样每一次操作极限时间复杂度还是很高,…
题意:https://nanti.jisuanke.com/t/31450 题解:题目很长的模拟,有点uva的感觉 分成四步 part1 16进制转为二进制string 用bitset的to_string() part2 parity check 校对,将处理结果pushback到另一个string part3 建字典树,用形如线段树的数组存 part4 遍历字典树 1A 233 #include<bitset> #include <cstdio> #include <cma…
Ka Chang 思路: dfs序+树状数组+分块 先dfs处理好每个节点的时间戳 对于每一层,如果这一层的节点数小于sqrt(n),那么直接按照时间戳在树状数组上更新 如果这一层节点个数大于sqrt(n),那么直接存一下这一层每个节点的大小(都是一样的),这样的层数不会超过sqrt(n)层 然后查询的时候先在树状数组查询答案,然后再遍历第二种层数,加到答案中 复杂度:n*sqrt(n)*log(n) 代码: #pragma GCC optimize(2) #pragma GCC optimiz…