PROGLANG - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3

Author: Daanish Mahajan
Tester: Anay Karnik
Editorialist: Mohan Abhyas

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

Chef is a software developer, so he has to switch between different languages sometimes. Each programming language has some features, which are represented by integers here.

Currently, Chef has to use a language with two given features A and B. He has two options — switching to a language with two features A_1 and B_1, or to a language with two features A_2 and B_2. All four features of these two languages are pairwise distinct.

Tell Chef whether he can use the first language, the second language or neither of these languages (if no single language has all the required features).

EXPLANATION:

Check if unordered pair (A,B) = any of unordered pairs (A_1,B_1) or (A_2,B_2) and answer accordingly

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

SOLUTIONS:

[details = “Editorial’s Solution”]

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define forn(i,e) for(ll i = 0; i < e; i++)

void solve()
{
    ll a,b,a1,b1,a2,b2;
    cin>>a>>b>>a1>>b1>>a2>>b2;
    if(a > b) swap(a,b);
    if(a1 > b1) swap(a1,b1);
    if(a2 > b2) swap(a2,b2);

    if(a == a1 && b == b1)
    {
        cout<<1<<endl;
    }
    else if(a == a2 && b == b2)
    {
        cout<<2<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
}

int main()
{
	ll t=1;
	cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}

whats wrong with this solution…
#include
using namescape std;
int main(){
int t;
cin>>t;
while(t–){
int a,b,a1,b1,a2,b2;
cin>>a>>b>>a1>>b1>>a2>>b2;
if(a+b==a1+b1) cout<<1<<endl;
else if(a+b == a2+b2) cout<<2<<endl;
else cout<<0<<endl;
}
return 0;
}

3 Likes

if a and b is 2and 2and a1 and b1 is 3 and 1 that will not give the real ans as sum of both of them is 4

1 Like

14 23 14 in this case tase case not pass.

#include <bits/stdc++.h>
using namespace std;

int main() {
int t,k;
cin>>t;
for(k=0;k<t;k++){
int a,b,a1,b1,a2,b2;
cin>>a>>b>>a1>>b1>>a2>>b2;
if(a==b1 || a==a1 && b==a1 || b==b1 ){
cout<<“1”<<’\n’;
}
else if(a==b2 || a==a2 && b==a2 || b==b2){
cout<<“2”<<’\n’;
}
else{
cout<<“0”<<’\n’;
}
}
return 0;
}
what is wrong in this