PROBLEM LINK:
Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4
Setter: Nandeesh Gupta
Tester: Abhinav Sharma, Aryan
Editorialist: Lavish Gupta
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
The Chef has reached the finals of the Annual Inter-school Declamation contest.
For the finals, students were asked to prepare 10 topics. However, Chef was only able to prepare three topics, numbered A, B and C — he is totally blank about the other topics. This means Chef can only win the contest if he gets the topics A, B or C to speak about.
On the contest day, Chef gets topic X. Determine whether Chef has any chances of winning the competition.
Print “Yes” if it is possible for Chef to win the contest, else print “No”.
You may print each character of the string in either uppercase or lowercase (for example, the strings yEs
, yes
, Yes
, and YES
will all be treated as identical).
EXPLANATION:
As mentioned in the problem statement, Chef can only win the contest if X is one of the A, B or C. So we will use a conditional statement to check this, and can answer accordingly.
TIME COMPLEXITY:
O(1) for each test case.
SOLUTION:
Editorialist's Solution
#include<bits/stdc++.h>
using namespace std ;
int main()
{
int a, b, c, x ;
cin >> a >> b >> c >> x ;
if(x == a || x == b || x == c)
cout << "Yes\n" ;
else
cout << "No\n" ;
return 0;
}