# CMC301 - Editorial

PUBG Mania

Author: artha6391
Tester: anushka_nagar
Editorialist: artha6391

CAKEWALK

None

# PROBLEM:

The problem wants us to find whether the selection criteria mentioned above is being satisfied in every input case and accordingly give the output for the same.

# QUICK EXPLANATION:

The problem criteria requires us to either select between given 2 categories (like between bronze and silver), and in some cases it requires us to only check whether the given category is present in the input (like diamond). This can be easily done with logical AND and OR operations.

# EXPLANATION:

Since in the given problem, we have 5 selection criterion, we shall take an array count[5] to keep check whether the given criterion has been satisfied in the input or not.
If among bronze and silver, any one of them is present in the input, we shall increment the value of the corresponding first index in count[].

count[0]++

The same can be done for every criterion.

Once all the conditions have been checked, we can perform a simple iteration through the count[] array and check whether all the values in the index are greater than 1. If they are, the selection criteria has been satisfied and “Yes” must be given as the output. Otherwise “No” should be given as the output.

Logical AND and OR operators can be used in the process as well.

# SOLUTIONS:

Setter’s Solution
``````#include <iostream>
using namespace std;

int main()
{
int t;
cin>>t;

for(int i=0;i<t;i++) {
int n;
cin>>n;
int count[5];

for(int j=0;j<5;j++)
count[j]=0;

char str[20];
for(int j=0;j<n;j++) {
cin>>str;
if(str[0]=='b')
count[0]++;
else if(str[0]=='s')
count[0]++;
else if(str[0]=='g')
count[1]++;
else if(str[0]=='p')
count[1]++;
else if(str[0]=='d')
count[2]++;
else if(str[0]=='c'&&str[5]=='\0')
count[3]++;
else if(str[0]=='a')
count[4]++;
else
count[4]++;
}

int f=0;
for(int j=0;j<5;j++) {
if(count[j]==0) {
f=1;
break;
}
}

if(f==1)
cout<<"No\n";
else
cout<<"Yes\n";
}
return 0;
}
``````
Tester’s Solution
``````#include <iostream>
using namespace std;

int main()
{
int t;
cin>>t;

for(int i=0;i<t;i++) {
int n;
cin>>n;
int count[5];

for(int j=0;j<5;j++)
count[j]=0;

char str[20];
for(int j=0;j<n;j++) {
cin>>str;
if(str[0]=='b')
count[0]++;
else if(str[0]=='s')
count[0]++;
else if(str[0]=='g')
count[1]++;
else if(str[0]=='p')
count[1]++;
else if(str[0]=='d')
count[2]++;
else if(str[0]=='c'&&str[5]=='\0')
count[3]++;
else if(str[0]=='a')
count[4]++;
else
count[4]++;
}

int f=0;
for(int j=0;j<5;j++) {
if(count[j]==0) {
f=1;
break;
}
}

if(f==1)
cout<<"No\n";
else
cout<<"Yes\n";
}
return 0;
}
``````
Editorialist’s Solution
``````#include <iostream>
using namespace std;

int main()
{
int t;
cin>>t;

for(int i=0;i<t;i++) {
int n;
cin>>n;
int count[5];

for(int j=0;j<5;j++)
count[j]=0;

char str[20];
for(int j=0;j<n;j++) {
cin>>str;
if(str[0]=='b')
count[0]++;
else if(str[0]=='s')
count[0]++;
else if(str[0]=='g')
count[1]++;
else if(str[0]=='p')
count[1]++;
else if(str[0]=='d')
count[2]++;
else if(str[0]=='c'&&str[5]=='\0')
count[3]++;
else if(str[0]=='a')
count[4]++;
else
count[4]++;
}

int f=0;
for(int j=0;j<5;j++) {
if(count[j]==0) {
f=1;
break;
}
}

if(f==1)
cout<<"No\n";
else
cout<<"Yes\n";
}
return 0;
}
``````