The Largest Clique
Time Limit: 3000MS 64bit IO Format: %lld & %llu
Description
Given a directed graph G, consider the following transformation.
First, create a new graph T(G) to have the same vertex set as G. Create a directed edge between two vertices u and v in T(G) if and only if there is a path between u and v in G that follows the directed edges only in the forward direction. This graph T(G) is often called the transitive closure of G.
We define a clique in a directed graph as a set of vertices U such that for any two vertices u and v in U, there is a directed edge either from u to v or from v to u (or both).
The size of a clique is the number of vertices in the clique.
Input
The number of cases is given on the first line of input. Each test case describes a graph G. It begins with a line of two integers n and m, where 0 ≤ n ≤ 1000 is the number of vertices of G and 0 ≤ m ≤ 50, 000 is the number of directed edges of G. The vertices of G are numbered from 1 to n. The following m lines contain two distinct integers u and v between 1 and n which define a directed edge from u to v in G.
Output
For each test case, output a single integer that is the size of the largest clique in T(G).
Sample Input
1
5 5
1 2
2 3
3 1
4 1
5 2
Sample Output
4
求最大点集使得集合中任意两个点u v 满足 u能到v || v能到u 。。。
那么在同一个SCC中的点要么全取(对答案贡献更大)要么全部不去,那么缩点之后拓扑排序进行dp就可以了。。。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<iomanip>
#include<ctime>