hdu6075 2019CCPC网络选拔赛1004 path】的更多相关文章

题意:给定一个带权有向图,有q组询问,每次询问在有向图的所有路径中,第k小的路径权值 解题思路:因为k最大只有5e4,考虑暴力搜索出前maxk小的路径并用数组记录权值,然后就可以O(1)查询. 具体实现:暴力搜索时可以借助Dijkstra最短路的思想,即用已知的最短路更新得出新的最短路.先将所有的边都装进一个multiset里面,然后每次将multiset里的首元素取出,作为新的答案,然后再用它来更新新的最短路,这样不断扩散的话就可以得到答案. 但是,这样可能会TLE或MLE,考虑再加加优化,首…
题意:给你一张n个点m条边的有向图,问这张有向图的所有路径中第k短的路径长度是多少?n, m, k均为5e4级别. 思路:前些日子有一场div3的F和这个题有点像,但是那个题要求的是最短路,并且k最大只有400.这个题的做法其实是一个套路(没见过QAQ). 首先把每个点的出边按边权从小到大排序,把每个点边权最小的那条边放入优先队列.对于优先队列中的每个点,记录一下这个点是从哪个点转移过来(last),转移过来的边对于last来说是第几小(rank).这时,从当前点now选一条边权最小的边,形成新…
path 题目传送门 解题思路 先用vector存图,然后将每个vector按照边的权值从小到大排序.将每个顶点作为起点的边里最短的边存入优先队列.对于存入优先队列的信息,应有边起点,终点,是其起点的第几短边,以及路径总长度.优先队列按照路径长度从小到大排序,每次出队当前最短的路径,对于一条路径,更新两条新的可能最短的路径,即这条路后面加上一条可走的最短边,以及这条路最后一条边换成一条次短边.将询问排序,不断更新答案即可. 代码如下 #include <bits/stdc++.h> #defi…
Problem Description Chisa Yukizome works as a teacher in the school. She prepares many gifts, which consist of n kinds with a[i] quantities of each kind, for her students and wants to hold a class meeting. Because of the busy work, she gives her gift…
题目链接 Problem Description Today is the birthday of SF,so VS gives two strings S1,S2 to SF as a present,which have a big secret.SF is interested in this secret and ask VS how to get it.There are the things that VS tell: Suffix(S2,i) = S2[i...len].Ni is…
题意 给你一个1~n的排列,由两种操作: 1 pos:将a[pos]+10 000 000 2 r k:求大于等于k且不等于a[1~r]的数的最小值. 强制在线. 思路 如果没有1操作,那么我们直接主席树就OK了. 考虑不真正的进行修改,每次1操作就把a[pos]插进set,因为加10 000 000后肯定是大于n的,而k是小于等于n的,所以set里的数是可以用的.要和1~r的数都不相同,那么我们用主席树查找区间r+1~n+1的大于等于k的最小值即可,为什么是n+1呢,因为k<=n,如果k==n…
题意:给出n个点m条边的有向图,问图上第K短路的长度是多少(这里的路可以经过任何重复点重复边). 解法:解法参考https://blog.csdn.net/Ratina/article/details/100066384这位大佬的. 比赛的时候也能想到用类似Dijkstra的做法用优先队列一条一条路拓展出来但是这样会MLE也没想到解决办法.后来看了题解才学会这个比较巧妙的优化办法. 朴素的办法就是向堆优化的Dijkstra一样把(u,dist)存入优先队列里然后每次从队列中找一个最小的dist出…
解题思路: fail树上用权值线段树合并求right/endpos集合,再用倍增找到待查询串对应节点,然后权值线段树求第k大. #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e5+5; int n,q; char s[maxn]; namespace SegTree{ int sum[maxn*100],L[maxn*100],R[maxn*100]; int tot1; i…
题意:给你一个长度为n的字符串,有q个询问,每次询问一个子串s(l,r)第k次出现的位置,若子串出现次数少于k次输出-1. 解题思路:先把SA跑出来,然后对于每次询问可以由l和rank[]找到l在所有后缀中的排名,再用两次二分求出使得LCP(L,R)包含s(l,r)的最大区间[L,R],LCP可以借助height[]的性质和ST表求得,即[L,R]包含rank[l]且min{height[L+1],height[L+2],...,height[R]}>=r-l+1.现在问题就转化为了求[L,R]…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6705 path Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1250    Accepted Submission(s): 257 Problem Description You have a directed weighted graph…
Robots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 60    Accepted Submission(s): 13 Problem Description QXJ has N robots on the plane, the i-th is at (xi,yi), numbereded 1 to N. Every robot…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6447 Problem DescriptionYJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination.One day, he is going to travel…
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6447 YJJ's Salesman Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 919    Accepted Submission(s): 290 Problem Description YJJ is a salesman who h…
Tree and Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 619    Accepted Submission(s): 214 Problem Description There are N vertices connected by N−1 edges, each edge has its own len…
目录 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 6702 & 6703 array 6704 K-th occurrence 6705 path 6706 huntian oy 6707 Shuffle Card 6708 Windows Of CCPC 6709 Fishing Master @ 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 CSDN 6702 & \(1 and 1\)的话,\(c\)就必须为\(1\).其他的贪心选\(0\). 注意c为…
$$2019中国大学生程序设计竞赛(CCPC)\ -\ 网络选拔赛$$ \(A.\hat{} \& \hat{}\) 签到,只把AB都有的位给异或掉 //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std; function<void(void)> ____ = [](){ios_base::sync_wit…
Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migic tree, the tree has N nodes , in each node , there is a treasure, it's value is V[i], and for each edge, there is a cost C[i], which means every time…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 300    Accepted Submission(s): 135 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake toge…
Divide Groups Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 423    Accepted Submission(s): 161 Problem Description   This year is the 60th anniversary of NJUST, and to make the celebration mor…
Save Labman No.004 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 624    Accepted Submission(s): 154 Problem Description Due to the preeminent research conducted by Dr. Kyouma, human beings hav…
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6438 Buy and Resell Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1233    Accepted Submission(s): 407 Problem Description The Power Cube is used…
/* HDU 6154 - CaoHaha's staff [ 构造,贪心 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 整点图,每条线只能连每个方格的边或者对角线 问面积大于n的图形最少要几条线 分析: 可以发现面积相同的情况下,每条线都连对角的菱形是最优的 再考虑如何将 面积为x^2的菱形,每次扩展一条边, 按最优扩展为面积为(x+1)^2的菱形 然后就可以先二分,再判断了 */ #include <bits/stdc++.h> using namespace std;…
思路来自 ICPCCamp /* HDU 6150 - Vertex Cover [ 构造 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 给了你一个贪心法找最小覆盖的算法,构造一组数据,使得这个程序跑出的答案是正解的三倍以上 分析: 构造一个二分图,左边 n 个节点 将左边的点进行 n 次分块,第 i 次分 n/i 块,每块的大小为 i,对于每一块都在右边建一个新的节点和这一块所有的点相连 则右边有 nlogn个节点,且每次一定优先选右边,最后取 nlogn >= 3n */…
普通的数位DP计算回文串个数 /* HDU 6156 - Palindrome Function [ 数位DP ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 2-36进制下回文串个数 */ #include <bits/stdc++.h> using namespace std; #define LL long long int t, L, R, l, r, base; int dig[40], tmp[40]; LL dp[40][40][40][2]; LL DFS(int p…
题目代号:HDU 6154 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 CaoHaha's staff Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 777    Accepted Submission(s): 438 Problem Description "You shal…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6709 Fishing Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 631    Accepted Submission(s): 170 Problem Description Heard that eom is a fishin…
2020ICPC·小米 网络选拔赛第一场 C-Smart Browser #include <string> #include <iostream> std::string s; void solve() { std::cin >> s; int ans = 0, t = s[0] == 'w'; for (int i = 1; i < s.size(); i++) { if (s[i] == 'w') { t++; } else { if (t != 0) {…
This world need more Zhu Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 262    Accepted Submission(s): 49 Problem Description As we all know, Zhu is the most powerful man. He has the infinite…
A Saving Tang Monk II #include <bits/stdc++.h> using namespace std; ; struct node { int x,y,z,t; }; struct cmp { bool operator() (node a,node b) { return a.t>b.t; } }; priority_queue<node,vector<node>,cmp>st; ]={-,,,}; ]={,-,,}; ]; ch…
Tree and Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description There are N vertices connected by N−1 edges, each edge has its own length.…