You are on page 1of 1

Problem Statement A survey team has a set of questions all of which can be answered in either „Yes‟ or „No‟.

Team interviews some people and asks any two questions from the set it is available with (a questions may be repeated i.e. asked to several people). Each person in the city answers the question in one of the following way (let q1 and q2 be the questions asked): i) Either answer to q1 is „yes‟ or answer to q2 is „yes‟ or both. ii) Either answer to q1 is „yes‟ or answer to q2 is „no‟ or both. iii) Either answer to q1 is „no‟ or answer to q2 is „yes‟ or both. iv) Either answer to q1 is „no‟ or answer to q2 is „no‟ or both. After recording responses to all the questions, the team works on figuring out the answers to individual questions assuming that each person knows the answers to all the questions and also he tell the correct answer to the survey team (in the specified format). Although it is possible that this assumption is wrong and logically, answers to all the questions can‟t be deduced from the responses. This means that no matter what are the answers to the questions, all the responses cannot be valid. Given responses to all the questions, you have to tell whether it is possible to assign a „yes‟ or „no‟ answer to all the questions, so that responses of all the people stand valid? { whether a logical deduction is possible on the basis of responses or not} Input: Your First input will be Integer type i.e Number of total questions (n) { q1, q2,………..qn } Your Second input will be Integer type i.e Number of total people interviewed (m) Your Third input will be string Type Array which contains Response list { list of m elements pairs of one of the four types(1<= x,y <= n ) given pair as x#y. } i) (x,y) which means “ either answer to „qx‟ is „yes‟ or answer to „qy‟ is „yes‟ or both” } ii) (x,-y) which means “ either answer to „qx‟ is „yes‟ or answer to „qy‟ is „no‟ or both” } iii) (-x,y) which means “ either answer to „qx‟ is „no‟ or answer to „qy‟ is „yes‟ or both” } iv) (-x,-y) which means “ either answer to „qx‟ is „no‟ or answer to „qy‟ is „no‟ or both” } Output: Your output will be string type Yes/No (Case Sensitive) Examples Examples 1: n =3, m = 2 and response list is (-1,2),(-1,-2) then it is possible to assign an answer to q1 („Yes‟) and q2 (either „Yes‟ or „no‟)which satisfies the given conditions. Examples 2: n =3, m = 3 and response list is (-1,2),(-1,-2)(1,2) then it is possible to assign an answer to q1 („Yes‟) and q2 ( „Yes‟ )which satisfies the given conditions. Examples 3: n =3, m = 4 and response list is (1,2),(1,-2),(-1,-2), (-1,2), then it is not possible to assign answers to q1 and q2 satisfying the answers of all the four people. None of the four possibilities for (q1,q2) i.e. („Yes‟,‟Yes‟),(„Yes‟,‟No‟),(„No‟,‟Yes‟),(„No‟,‟No‟) satisfies all the four responses.