# Utkarsh and Placement tests UTKPLC Solution Codechef

Page Contents

## Utkarsh and Placement tests UTKPLC Solution

Utkarsh is currently sitting for placements. He has applied to three companies named A,BA,B, and CC.

You know Utkarsh’s order of preference among these 33 companies, given to you as characters `first``second`, and `third` respectively (where `first` is the company he prefers most).

You also know that Utkarsh has received offers from exactly two of these three companies, given you as characters xx and yy.

Utkarsh will always accept the offer from whichever company is highest on his preference list. Which company will he join?

### Input Format

• The first line of input contains a single integer TT, denoting the number of test cases. The description of TT test cases follows.
• The first line of each test case contains three different space-separated characters: `first``second`, and `third`, denoting Utkarsh’s order of preference among the three companies.
• The second line of each test case contains two space-separated characters xx and yy, the companies from which Utkarsh has received offers.

### Output Format

For each test case, print one line containing a single character, the company whose offer Utkarsh will accept.

The output is not case sensitive, so if the answer is AA, both aa and AA will be accepted.

### Constraints

• 1≤T≤361≤T≤36
• `first``second` and `third` are three different characters among {A,B,C}{A,B,C}.
• xx and yy are two different characters among {A,B,C}{A,B,C}.

Subtask #1 (100 points): Original constraints

```2
A B C
A B
B C A
A C
```

```A
C
```

### Explanation

Test Case 1. Utkarsh has received offers from AA and BB. Of these two, he prefers company AA (first preference) over BB (second preference). Therefore Utkarsh will accept the offer of company AA.

Test Case 2. Utkarsh has received offers from AA and CC, where company CC is his second preference and company AA is his third preference. Utkarsh will accept the offer of company CC.

## SOLUTION

Program Python: Utkarsh and Placement tests UTKPLC Solution in Python

```for _ in range (int(input())):
a,b,c=map(str,input().split())
d,e=map(str,input().split())
if a == d:
print(d)
elif a == e:
print(e)
elif b==d:
print(d)
else:
print(e)```

Program C++: Utkarsh and Placement tests UTKPLC Solution in C++

Credit: pirate_helper (in comment section)

```#include <iostream>
using namespace std;

int main() {
int t;
cin >> t;
while(t--) {
char first , second, third,x,y;
cin >> first >> second >> third;
cin >> x >> y;
if(first == x) {
cout << x << endl;
} else if(first ==y) {
cout << y << endl;
} else if(second ==x){
cout << x <<endl;
}else{
cout << y << endl;
}
}
return 0;
}```

## December Long Challenge 2021 Solution

### 2 thoughts on “Utkarsh and Placement tests UTKPLC Solution Codechef”

1. #include

using namespace std;

int main() {
int t;
cin >> t;
while(t–) {
char first , second, third,x,y;
cin >> first >> second >> third;
cin >> x >> y;
if(first == x) {
cout << x << endl;
} else if(first ==y) {
cout << y << endl;
} else if(second ==x){
cout << x <<endl;
}else{
cout << y << endl;
}
}
return 0;
}

• 