# PROBLEM LINK:

Contest Division 1

Contest Division 2

Contest Division 3

Contest Division 4

Setter: Srikkanth R

Tester: Abhinav Sharma, Aryan

Editorialist: Lavish Gupta

# DIFFICULTY:

Cakewalk

# PREREQUISITES:

None

# PROBLEM:

The National Championships are starting soon. There are 4 race categories, numbered from 1 to 4, that Chef is interested in. Chef is participating in exactly 2 of these categories.

Chef has an arch-rival who is, unfortunately, the only person participating who is better than Chef, i.e, Chef can’t defeat the arch-rival in any of the four race categories but can defeat anyone else. Chef’s arch-rival is also participating in exactly 2 of the four categories.

Chef hopes to not fall into the same categories as that of the arch-rival.

Given X, Y, A, B where X, Y are the races that Chef participates in, and A, B are the races that Chef’s arch-rival participates in, find the **maximum** number of gold medals (first place) that Chef can win.

# EXPLANATION:

## In which race can Chef win a gold medal?

Consider a race R. If the Chef’s arch-rival is participating in the race R then Chef cannot win a gold medal in this race. However, if the Chef’s arch-rival is not participating in the race R then Chef can win a gold medal in this race.

## Can Chef win a gold medal in race X?

Chef’s arch-rival is participating in the races A and B. If none of the A or B is equal to X, then Chef can win a gold medal in race X.

## Can Chef win a gold medal in race Y?

Chef’s arch-rival is participating in the races A and B. If none of the A or B is equal to Y, then Chef can win a gold medal in race Y.

## Maximum number of gold medals that Chef can win

If Chef cannot win a gold medal in any of the races X or Y, then the answer is 0.

If Chef can win a gold medal in exactly one of the races X or Y, then the answer is 1.

If Chef can win a gold medal in both the races X and Y, then the answer is 2.

# TIME COMPLEXITY:

O(1) for each test case.

# SOLUTION:

## Editorialist's Solution

```
#include<bits/stdc++.h>
using namespace std ;
int main()
{
int t ;
cin >> t ;
while(t--)
{
int x, y, a, b ;
cin >> x >> y >> a >> b ;
int gold = 0 ;
if(x != a && x != b)
gold++ ;
if(y != a && y != b)
gold++ ;
cout << gold << endl ;
}
return 0;
}
```