图论
我他喵的
这个作者很懒,什么都没留下…
展开
-
HDU1814 Peaceful Commission(2-SAT输出字典序最小的解)
题目链接题意现在有n个党派,每个党派拥有两个候选代表,第i个党派的候选代表为2i-1和2i,两个党派候选人只会有一个去参加会议,此外还有m对候选人互相看不顺眼,只能去其中一个,求字典序最小的代表人选。思路一个比较明显的2-SAT问题,但是需要输出最小解,所以似乎不可以用传统的拓扑排序寻找可行解,于是采取了DFS解法,复杂度O(nm),其能选取出最小解的原因应该是采取了顺序的遍历方式。代码#include<bits/stdc++.h>using namespace std;con原创 2021-05-01 10:30:23 · 161 阅读 · 0 评论 -
POJ3268 Silver Cow Party(多次Dijkstra)
题目链接DescriptionOne cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1…N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roads connects pairs of farms; road i requ原创 2020-07-30 04:49:56 · 123 阅读 · 0 评论 -
POJ2728 Desert King(01分数规划+Prime)
题目链接题意求最优比例生成树,即令∑cost[i]/∑dis[i]=ans尽可能小,对式子略作改变化为∑cost[i]-ans×dis[i]=0。由于ans未知,所以通过0/1分数规划+Prime对∑cost[i]-s×∑dis[i]=w进行求解。#include<bits/stdc++.h>using namespace std;const int mod=100000073;const int maxn=1e3+5;typedef long long ll;const int原创 2020-07-29 08:19:10 · 125 阅读 · 0 评论 -
HDU1845 Jimmy’s Assignment(匈牙利算法)
题目链接Jimmy’s AssignmentJimmy is studying Advanced Graph Algorithms at his university. His most recent assignment is to find a maximum matching in a special kind of graph. This graph is undirected, has N vertices and each vertex has degree 3. Furthermore,原创 2020-07-28 17:32:20 · 177 阅读 · 0 评论 -
HDU3339 In Action(Dijkstra+01背包)
题目链接In ActionSince 1945, when the first nuclear bomb was exploded by the Manhattan Project team in the US, the number of nuclear weapons have soared across the globe.Nowadays,the crazy boy in FZU named AekdyCoin possesses some nuclear weapons and wanna原创 2020-07-26 08:01:53 · 178 阅读 · 0 评论