C00K0FF - Editorial

PROBLEM LINK

Practice

Contest

Author: Hanlin Ren

Tester: Jakub Safin

Editorialist: Jakub Safin

DIFFICULTY

CAKEWALK

PREREQUISITIES

none

PROBLEM

Determine if it’s possible to select 5 problems with required difficulties for a Cook-Off, given a list of N problems with known difficulties.

QUICK EXPLANATION

Straightforward - check the given conditions.

EXPLANATION

As the easiest problem in this contest, there isn’t much to be said about its solution.

Notice that there are no overlaps among the difficulties required for the 5 problems, so we can just independently check for each problem if at least one of the required difficulties for it appears among the input strings.

We don’t even need to remember all the input strings - it’s enough to remember how many times each of them appeared in the input. That makes checking the required conditions even easier.

Time complexity: O(N). Memory complexity: O(1).

CHALLENGE

Too easy? You can think about how this problem could be generalised. An arbitrary number of difficulties, arbitrary lists of allowed difficulties for each spot, upper or lower bounds on the total number of used problems of each difficulty, etc…

AUTHOR’S AND TESTER’S SOLUTIONS

Setter’s solution

Tester’s solution

#include <bits/stdc++.h>
// iostream is too mainstream
#include
// bitch please
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int T;
	cin >> T;
	string diff[] ={
		"cakewalk",
		"simple",
		"easy",
		"easy-medium",
		"medium",
		"medium-hard",
		"hard"
	};
	for(int t =0; t < T; t++) {
		int cnt[] ={0,0,0,0,0,0,0};
		int N;
		cin >> N;
		for(int i =0; i < N; i++) {
			string s;
			cin >> s;
			for(int j =0; j < 7; j++) if(diff[j] == s) cnt[j]++;
		}
		if(cnt[0] && cnt[1] && cnt[2] && cnt[3]|cnt[4] && cnt[5]|cnt[6]) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;}

// look at my code
// my code is amazing

Would have been more amazing if you’d had shared only solution link instead of copy pasting the entire code. :slight_smile:

I did this question using set

if set size was 5 then print yes

else print no

here is the link to my solution

https://www.codechef.com/viewsolution/15560862

simple
medium-hard
medium
hard
easy
easy-medium
cakewalk

The problem statement says we should check for exactly one cakewalk, one simple,one easy
But the editorial solution works for the cases even when there is more than one cakewalk or simple or easy…!

1 Like

The contest must contain exactly one. You have to choose contest problems from the list given. You have to make sure that from the list of problems, you choose exactly one of them. Hope that clears!

It is because we then have a choice for selecting the question and we have atleast one of them . In the contest we have to choose exactly one . It doesn’t matter if that question is the only one in the pool or one among many .

Why would you just copy and paste the tester’s solution?

https://www.codechef.com/viewsolution/15827238
heres my code … could somebody help me get out of it…

@youknowwho96 yes the language of the problem is saying exactly one for ck , si and esy
but solution is accepting for these>1 also

1 Like