GHOSTS - Ghosts having fun
Ghost are living in big castle with K rooms.
As they have around few hundred years and very tired, they decided to buy teleports. Every teleport can work only in one way (to prevent collision). Ghosts have decided which teleports they want to build and in which order they should be built.
King of ghosts, Bob, asked you to check list of teleports and decide which of them do not build. He don't want ghosts having fun in infinite ride with teleports.
Input
In first line - number K <= 1000, number of rooms in castle.
In next line - number T <= 300000 number of teleports.
In next T lines a, b <= K
Rooms are numbered 1 to K
Output
Print teleports which should not be built. End test case with 0 0.
Example
Input: 4 5 2 4 4 3 3 2 1 2 3 1 Output: 3 2 3 1 0 0
hide comments
ishaan_23o:
2022-07-29 15:46:30
done in 42nd go without bitset (˃̣̣̥ᴖ˂̣̣̥) |
|
tru3r00t:
2022-06-05 09:00:46
why cant we use a DSU?
|
|
darshan_07:
2021-01-12 12:16:37
any hint ?? how to solve problem..??
|
|
joe85123:
2019-08-28 15:38:06
nice concept but bad problem statement...
|
|
narek:
2018-08-28 02:39:37
Hint: bitset :) |
|
shubham_001:
2017-07-05 10:22:51
@codesmiler you can't print 1 2 instead of 3 1 because you've got 1 2 earlier till then there was no 3 1 ,so after putting teleport 1 2 you got 3 1 so remove that 3 1 and answer should be in order indeed |
|
codesmiler:
2016-10-18 16:41:41
why can't we remove 1 2,3 2 |
|
iharsh234:
2016-08-30 21:40:01
6
|
|
apar03:
2016-06-17 15:18:27
O(T*K^2) giving TLE :/ Last edit: 2016-06-17 15:18:58 |
|
shikhar0037:
2016-06-02 21:30:27
Finally accepted after getting many RTE :) very silly mistake |
Added by: | Krzysztof Lewko |
Date: | 2011-08-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |