i don’t understand the input statement which is “There is a blank line after each test case .In the case there is no relation between two beverages Dilbert should start drinking the one that appears first in the input. The input is terminated by end of line (EOF)”.
due to this i cant understand the ouput in the test case.
please tell in detail about concept of this question.
Vivek and party
The problem simply asks you to find an order or drinks, such that the given relation holds true.
a b
c d
b c
Then possible order is abcd since it satisfies all conditions. (a appears before b, c appears before d, b appears before c)
but this is contradicting with what u said as
a,e a,b c,d but in output e comes after b,c,d
please elaborate with the first test case given in the question
Okay let’s take the first test case.
8
a
b
c
d
e
f
s
t
6
a e
a b
c d
e f
s t
a t
We need to print lexicographically smallest order of drinks, which satisfy the given 6 conditions.
According to given conditions, A must appear before B,E,T ; C must appear before D ; E must appear before F ; S must appear before T
Hence if you check ABCDEFST holds these conditions true.
You shall relate this problem with topological sorting.
I hope this clears the question 
Thanks
please elaborate the answer of the following test case
a,b,d,e,f,s,t and conditons are : 5 b c, d a, s t, f e , a t
B C D A F E S T
Check all conditions, do they satisfy ?
And is it lexicographically smallest permutation?
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
now doubt is that as in my given test case t comes before f but you have put t after f in the answer
i don’t think it is satisfying given condition of t coming before f
Hey see, We are given some conditions. They must be followed.
Now for some alphabets, there are options weather to put them before or after. Like t and f. So we need to see what the output demands. In the sample case , I think they want lexicographically, so i put f before t.
If you feel that question demands whatever alphabet occurs first shall be first in output, you may try that.