Programming Languages solution codechef

Programming Languages solution codechef

Chef is a software developer, so he has to switch between different languages sometimes. Each programming language has some features, which are represented by integers here.

Currently, Chef has to use a language with two given features AA and BB. He has two options — switching to a language with two features A1A1 and B1B1, or to a language with two features A2A2 and B2B2. All four features of these two languages are pairwise distinct.

Tell Chef whether he can use the first language, the second language or neither of these languages (if no single language has all the required features).

Input Format Programming Languages solution codechef

  • The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
  • The first and only line of each test case contains six space-separated integers A,B,A1,B1,A2,B2A,B,A1,B1,A2,B2.

Output Format

For each test case, print a single line containing the integer 11 if Chef should switch to the first language, or 22 if Chef should switch to the second language, or 00 if Chef cannot switch to either language.

Constraints Programming Languages solution codechef

  • 1T2881≤T≤288
  • 1A,B,A1,B1,A2,B241≤A,B,A1,B1,A2,B2≤4
  • A,BA,B are distinct
  • A1,B1,A2,B2A1,B1,A2,B2 are pairwise distinct


Subtask #1 (100 points): original constraints

Sample Input 1  Programming Languages solution codechef 

1 2 2 1 3 4
3 4 2 1 4 3
1 2 1 3 2 4

Sample Output 1 


Explanation Programming Languages solution codechef

Example case 1: The first language has the required features — features 11 and 22.

Example case 2: The second language has the required features — features 33 and 44.

Example case 3: Neither language has both features 11 and 22.

Leave a Comment

Your email address will not be published.