Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2714 Accepted Submission(s): 1128
Problem Description
Give a simple directed graph with N nodes and M edges. Please tell me the maximum number of the edges you can add that the graph is still a simple directed graph. Also, after you add these edges, this graph must NOT be strongly connected.
A simple directed graph is a directed graph having no multiple edges or graph loops. A strongly connected digraph is a directed graph in which it is possible to reach any node starting from any other node by traversing edges in the direction(s) in which they point.
Input
The first line of date is an integer T, which is the number of the text cases.
Then T cases follow, each case starts of two numbers N and M, 1<=N<=100000, 1<=M<=100000, representing the number of nodes and the number of edges, then M lines follow. Each line contains two integers x and y, means that there is a edge from x to y.
Output
For each case, you should output the maximum number of the edges you can add.
If the original graph is strongly connected, just output -1.
#include
#include
#include
#include
#include
using namespace std;
#define N 100000+10
vectorlink[N];
bool inStack[N];
int dfn[N];
int low[N];
int fa[N];//通过DAG图中 某个顶点所属的强连通分量序号
int point[N];//统计缩点后某强连通分量的顶点数
int in[N];//缩点后某强连通分量的入度
int out[N];//缩点后某强连通分量的出度
int time;//时间戳
int sum;//DAG图中连通分量的个数
int n,m;
stacks;
void doTarjan(int x)
{
dfn[x]=low[x]=++time;
s.push(x);
inStack[x]=true;
for(int i=0;i
继承 extends 多态
继承是面向对象最经常使用的特征之一:继承语法是通过继承发、基类的域和方法 //继承就是从现有的类中生成一个新的类,这个新类拥有现有类的所有extends是使用继承的关键字:
在A类中定义属性和方法;
class A{
//定义属性
int age;
//定义方法
public void go
hive DDL语法汇总
1、对表重命名
hive> ALTER TABLE table_name RENAME TO new_table_name;
2、修改表备注
hive> ALTER TABLE table_name SET TBLPROPERTIES ('comment' = new_comm