SOCKS1 - Editorial

PROBLEM LINK:

Practice
Div-3 Contest

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;
                }

@daanish_adm , @admin Contest is still live , unlist the editorial

Lmao, I already said that in BOLT editorial and nobody gave shit about it, so I guess either

A - someone is really trying to get the round unrated
or B - CodeChef is in the process of decomposition as usual

I’m strongly rooting for B, but hey place your bets! :wink:

2 Likes

What is the use of const int maxv = 10; here in Setter’s Solution ?

He is just setting the max value as 10 as per the constraints. Just a habit I guess, no biggie for cake walk problems.