摘要: lca。 3个点分别lca,可以知道,深度最深的lca就是答案。 #include #include #include using namespace std; const int maxn = 500000 + 10; const int maxm = 1000000 + 10; const int maxl = 22; int g[maxn],v[maxm],next[maxm],... 阅读全文
posted @ 2016-06-08 23:49 invoid 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 状压dp。 #include #include #include using namespace std; const int maxn = 12; int f[1<<maxn][1010],cnt[maxn],fac[maxn]; char s[maxn]; int T,d,N,n; int main() { fac[0]=1; for(int i=1;i<=10;i... 阅读全文
posted @ 2016-06-08 19:23 invoid 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 最小费用最大流。 这道题的特点在于每个修车的人所需要等待的时间要加上之前这个技术人员维修车的时间。 直观地我们可以每个技术人员建造n个点,费用分别为k*t(k=1,2,3…)(t为维修时间)。 但是这样很可能会超时,我们又发现,因为总共只有n个人来修车,我们每次用过每个修车人员后,再临时增加点,就可以避免浪费。 决策时,就变成了这个技术人员倒数第几个修这个车。 语言比较混乱,但这道题是好... 阅读全文
posted @ 2016-06-08 18:03 invoid 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 网络流 首先算出每行每列的数的和。 每行的值减去c,每列的值减去R 然后每行和每列之间连边,容量为19. 这样一来,(i,j)的流量相当于(i,j)的值-1. 这样就避免了流量为0不对应答案的尴尬情况。 #include #include #include using namespace std; const int maxn = 1000 + 10; const int max... 阅读全文
posted @ 2016-06-08 09:40 invoid 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 最大流。 流可以对应一种分配方式。 显然最大流就可以表示最多匹配数 #include #include #include using namespace std; const int maxn = 500 + 10; const int maxm = 100000 + 10; const int maxl = 30; const int inf = 0x3f3f3f3f; char ... 阅读全文
posted @ 2016-06-08 09:32 invoid 阅读(128) 评论(0) 推荐(0) 编辑