Code: #include <bits/stdc++.h> #define ll long long #define setIO(s) freopen(s".in","r",stdin) #define maxn 3002 using namespace std; queue<int>Q; vector<int>G[maxn]; int n,m,s1,t1,l1,s2,t2,l2; int vis[maxn],d[maxn][m…
看到没有题解就贡献一波呗 分析: 这题其实就是想让我们求一个图中两条最短路的最短(好把更多的边删掉). 我们先考虑一条最短路,别问我我怎么会的显然,就是s和t跑个最短路再用n-就行. 然后就是两条喽!这不就是做两次吗,我太巨了! 这当然是可以的 --不过只是一种情况 考虑到我们的两条路径可能会有重合,我们只好枚举重合最短路的左右端点,将路径分为5段(6段?)来处理. 然后问题基本就解决了,最开始把两两点之间预处理出最短路,这里要注意bfs即可别告诉我你要用Floyd 最后的答案如果比m大就-1了…
B. Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with int…
Destroying Roads 题目链接 题意 n个点,m条边每两个点之间不会有两个相同的边,然后给你两个起s1,s2和终点t1,t2; 求删除最多的边后满足两个s1到t1距离\(<=l1\),s2到t2的距离\(<=l2\) 求能删除最多的边. 思路 先bfs求出每两个点之间的最短路,然后暴力枚举两条路径的重合路径,枚举时有两种组合,$$(s1,s2)(t1,t2)||(s1,t2)(s2,t1)$$ 枚举的重合路径为[i][j],所以可以删除的边为总的边数减去满足两个条件所要求的最小边数…
Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with intege…
题目链接: 题目 D. Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes inputstandard input outputstandard output 问题描述 In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbe…
B - Destroying Roads 思路:这么菜的题我居然想了40分钟... n^2枚举两个交汇点,点与点之间肯定都跑最短路,取最小值. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define y1 skldjfskldjg #define y2 skldfjsk…
D - Destroying Roads Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/problem/D Description In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers f…
D. Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with int…
标题:危险系数 抗日战争时期,冀中平原的地道战曾发挥重要作用. 地道的多个站点间有通道连接,形成了庞大的网络.但也有隐患,当敌人发现了某个站点后,其它站点间可能因此会失去联系.        我们来定义一个危险系数DF(x,y):     对于两个站点x和y (x != y), 如果能找到一个站点z,当z被敌人破坏后,x和y不连通,那么我们称z为关于x,y的关键点.相应的,对于任意一对站点x和y,危险系数DF(x,y)就表示为这两点之间的关键点个数. 本题的任务是:已知网络结构,求两站点之间的危…