题意其实就是给你一个有向图 但是每个SCC里面的点数目不超过5 求最长路 首先暴力把每个SCC里的每个点的最长路跑出来 然后拓扑排序dp 然后因为tarjan 搜索树出来的SCC是拓扑排好序的 可以直接dp #include<bits/stdc++.h> #define MOD 1000000007 using namespace std; typedef long long ll; ; vector< * N], g2[N]; int dfn[N], low[N], bel[N], d…
题意:求一个有向图上的最长路(每个强连通分量的点不超过5个) 首先对强连通分量缩点,暴力预处理出len[k][i][j]表示第k个强连通分量里的第i个点和第j个点之间的最长路径,设状态(k,i,f)表示在第k个强连通分量的第i个点,f表示是否已经在内部发生了转移(每个强连通分量内部只允许转移一次),然后记忆化搜索即可. #include<bits/stdc++.h> using namespace std; ; int n,m,hd[N],ne,low[N],dfn[N],nscc,scc[N…
有向图,不经过重复点的最长链,强连通分量大小不超过5. 每个强连通分量内部暴力预处理任意两对点之间的最长路,外面DAG上dp. 不是很好写,但是预处理完了之后,可以重构每个强连通分量内部的结构,然后整个就变成一张DAG了,就很方便了. #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <…
Grouping Time Limit: 2 Seconds      Memory Limit: 65536 KB Suppose there are N people in ZJU, whose ages are unknown. We have some messages about them. The i-th message shows that the age of person si is not smaller than the age of person ti. Now we…
Father Christmas flymouse Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 3007   Accepted: 1021 Description After retirement as contestant from WHU ACM Team, flymouse volunteered to do the odds and ends such as cleaning out the computer…
P3119 [USACO15JAN]草鉴定Grass Cownoisseur 题目描述 In an effort to better manage the grazing patterns of his cows, Farmer John has installed one-way cow paths all over his farm. The farm consists of N fields, conveniently numbered 1..N, with each one-way co…
迷宫城堡 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9893    Accepted Submission(s): 4433 Problem Description 为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N<=10000)和M条通道(M<=100000),每一个通道都是单向的,就是说若称某通道连通了…
Instantaneous Transference Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6177   Accepted: 1383 Description It was long ago when we played the game Red Alert. There is a magic function for the game objects which is called instantaneous…
一个有向图G=(V,E)称为半连通的(Semi-Connected),如果满足:?u,v∈V,满足u→v或v→u,即对于图中任意两点u,v,存在一条u到v的有向路径或者从v到u的有向路径.若G'=(V',E')满足V'?V,E'是E中所有跟V'有关的边,则称G'是G的一个导出子图.若G'是G的导出子图,且G'半连通,则称G'为G的半连通子图.若G'是G所有半连通子图中包含节点数最多的,则称G'是G的最大半连通子图.给定一个有向图G,请求出G的最大半连通子图拥有的节点数K,以及不同的最大半连通子图…
Instantaneous Transference Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6204   Accepted: 1389 Description It was long ago when we played the game Red Alert. There is a magic function for the game objects which is called instantaneous…