PROBLEM LINK:
Author & Editorialist: Daanish Mahajan
Testers: Shubham Jain, Aryan Choudhary
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
Given Chef has 3 socks with colours A, B, C \in [1, 10], tell whether atleast 2 socks have the same colour.
EXPLANATION:
We can just check manually that whether there exists a valid pair by comparing all the pairs.
Comparison
string ans = ((A == B || B == C || A == C) ? “YES” : “NO”)
or we can take the input in a vector and sort it and compare only the adjacent values.
SOLUTIONS:
Setter's Solution
#include<bits/stdc++.h>
using namespace std;
const int maxv = 10;
int main()
{
int s1, s2, s3; cin >> s1 >> s2 >> s3;
string ans = ((s1 == s2 || s2 == s3 || s1 == s3) ? "YES" : "NO");
cout << ans << endl;
}
Tester's Solution
#include<bits/stdc++.h>
using namespace std;
vector<int> readVectorInt(long long int l,long long int r,int n){
vector<int> a(n);
for(int i=0;i<n;++i)
cin >> a[i];
return a;
}
long long int T,n,i,j,k,in,cnt,l,r,u,v,x,y;
vector<int> a;
int main(void) {
ios_base::sync_with_stdio(false);cin.tie(NULL);
a=readVectorInt(1,10,3);
sort(a.begin(), a.end());
cout<<(a[1]==a[0]||a[1]==a[2]?"YeS":"nO")<<endl;
return 0;
}