逃不掉的路 CH Round #24 - 三体杯 Round #1 题目描述 现代社会,路是必不可少的.任意两个城镇都有路相连,而且往往不止一条.但有些路连年被各种XXOO,走着很不爽.按理说条条大路通罗马,大不了绕行其他路呗--可小撸却发现:从a城到b城不管怎么走,总有一些逃不掉的必经之路. 他想请你计算一下,a到b的所有路径中,有几条路是逃不掉的? 输入格式 第一行是n和m,用空格隔开.接下来m行,每行两个整数x和y,用空格隔开,表示x城和y城之间有一条长为1的双向路.第m+2行是q.接下来…
题目 City C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, the mayor plans to build a RTQS (Real Time Query System) to monitor all traffic situations. City C is made up of N crossings and M roads, and each road…
题目 City C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, the mayor plans to build a RTQS (Real Time Query System) to monitor all traffic situations. City C is made up of N crossings and M roads, and each road…
按照vdcc缩点之后一条边只会属于一个新的点集,由于这棵树上满足(不是割点) - (割点) - (不是割点)的连接方法,所以求两条边之间的必经点就是(树上距离 / 2),倍增跳lca即可 考虑到缩点后树上点数的编号可能超过n,所以与树有关的数组开两倍N 又是一个模板 Code: #include <cstdio> #include <cstring> #include <vector> using namespace std; ; ; ; ][N << ],…
P.S.此题无代码,只有口胡,因为作者码炸了. 题目大意 给你一个有 \(n\) 个点, \(m\) 条边的无向图,进行 \(q\) 次询问,每次询问两个点 \(u\) \(v\),输出两个点的之间的路径经过了几个割点. 题解 这是一道模板题,先考虑用 \(Tarjan\) 求出割点的位置,再选择缩点.由于我们要缩的是点双连通分量,所以与强连通分量和边双连通分量有所不同.正解好像是圆方树,但是作者这里使用的是自己口胡的一种方法(一直过不了可能就是因为它,但是找不出错). 对于这样的一个图,我们不…
题目大意: 有一张无向连通图,问从一条边走到另一条边必定要经过的点有几个. 思路: 先用tarjan将双连通分量都并起来,剩下的再将割点独立出来,建成一棵树,之后记录每个点到根有几个割点,再用RMQ求LCA计算. 注意:数组范围. 代码: #include<cstdio> #include<vector> #include<iostream> #include<algorithm> using namespace std; ,M=; ],v[M<<…
Traffic Real Time Query System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1929    Accepted Submission(s): 380 Problem Description City C is really a nightmare of all drivers for its traffi…
HDU 3686 Traffic Real Time Query System 题目大意 给一个N个点M条边的无向图,然后有Q个询问X,Y,问第X边到第Y边必需要经过的点有多少个. solution 显然园方树+tarjan求LCA,然后求两条边之间的点 必经的点的数量就是圆点的数量,然后进行分类讨论 若\(LCA\)为圆点: 那么其中一个点到\(LCA\)的圆点数量为\((deep[x] - deep[lca])/2\),因为\(LCA\)为圆点被算了两遍,所以要-1 若\(LCA\)为方点:…
Problem Description City C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, the mayor plans to build a RTQS (Real Time Query System) to monitor all traffic situations. City C is made up of N crossings and M roa…
题目描述 City C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, the mayor plans to build a RTQS (Real Time Query System) to monitor all traffic situations. City C is made up of N crossings and M roads, and each ro…