Как решить проблему круга друзей с помощью динамического программирования?
2N friends(A,B,C...,2N) are standing in the Circle.There is exactly one person standing opposite of one other person. Some of them are facing inward and some of them are facing outwards. given some facts our task is to build standing positions and answer a few questions. If Arrangement not possible or more than one arrangement possible then print "ARRANGEMENT NOT POSSIBLE"
Facts "1AB" means : A and B are standing adjacent to each other "2AB" means : A and B are standing opposite to each other "3AB" means : A is standing to the immediate left of B "4AB" means : A is standing to the immediate right of B "5A" means : A is facing inwards "6A" means : A is facing outwards "7n" means : n peoples are facing inwards, where n is a number "8n" means : n peoples are facing outwards, where n is a number Questions "?2A" means : who is standing opposite of A "?3A" means : who is standing to the immediate left of A "?4A" means : who is standing to the immediate right of A "?5A" means : is A facing inwards?Ans: Y/N "?6A" means : is A facing outwards?Ans: Y/N Constraints 1<N<10 1< TOTAL FACTS < 30 1 < Total Questions < 20 Input Format N multiple facts, separated by semicolon multiple questions separated by semicolon Explanation Example 1 Input 2 2AB;72;1AC;6D;4BD;6C ?2D;?3C;?4B;?5A;?6B output C;B;D;Y;N Explanation 4 people are A, B, C and D are standing in a circle There are 6 facts separated by semicolon 2AB > A and B are standing opposite 72 > 2 people are facing inwards 1AC > A and C are standing nearby 6D > D is facing outwards 4BD > B is standing immediate right of D 6C > C is facing outwards
Что я уже пробовал:
Я понятия не имею, как это решить