-
Notifications
You must be signed in to change notification settings - Fork 0
/
chef and races
39 lines (36 loc) · 1.37 KB
/
chef and races
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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.
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=sc.nextInt();
int count=2;
if((c==a)||(c==b)){
count=count-1;
}
if((d==a)||(d==b)){
count=count-1;
}
System.out.println(count);
}// your code goes here
}
}