题目大意:给定一张无向图,求一个拓扑序,使:
1的位置最靠前
在保证上面的条件下使2的位置最靠前
在保证上面的条件下使3的位置最靠前
……
注意不是字典序最小!例如样例3
建立反图,对反图求字典序最大的拓扑序,然后反向输出即可。
我不知道为什么。真的不知道。
求个解答在线等。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define M 100100
using namespace std;
struct abcd{
int to,next;
}table[M];
int head[M],tot;
int n,m;
int