luogu#P7056. [NWRRC2015] Insider’s Information
[NWRRC2015] Insider’s Information
题目描述
Ian works for a rating agency that publishes ratings of the best universities. Irene is a journalist who plans to write a scandalous article about the upcoming rating.
Using various social engineering techniques (let's not get into more details), Irene received some insider's information from Ian.
Specifically, Irene received several triples meaning that in the upcoming rating, university stands between universities and That is, either comes before which comes before or the opposite. All triples told by Ian are consistent -- let's say that actual rating satisfies them all.
To start working on the first draft of the future article, Irene needs to see at least some approximation to the actual rating. She asked you to find a proposal of a rating in which at least half of the triples known by Irene are satisfied.
输入格式
The first line contains integers and , the number of rated universities, and the number of triples given to Irene by Ian ; .
Each of the next lines contains three distinct integers -- the universities making a triple .
输出格式
Output the proposal of a rating from the first university to the last one. The proposal rating should satisfy at least triples. If there are many such proposals, output any one of them.
题目大意
题意
对于 的排列,给 个限制,第 个限制描述 出现在 , 之间。保证存在一个排列满足所有限制。
构造一个 的排列至少满足 个限制。
4 3
1 2 3
1 2 3
1 4 3
4 3 2 1
提示
Time limit: 2 s, Memory limit: 256 MB.