SNCKYEAR - EDITORIAL

PROBLEM LINK:

Practice
Contest

Setter: Misha Chorniy
Tester: Hasan Jaddouh
Editorialist: Taranpreet Singh

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

Given a year, determine whether SnackDown was hosted in that year or not. SnackDown was hosted in years 2010, 2015, 2016, 2017 and 2019.

SUPER QUICK EXPLANATION

  • Explanation is even quicker.

EXPLANATION

Read the number, and check if N is one of the above years. If yes, print “HOSTED”. Otherwise, print “NOT HOSTED”.

If-else clause or set can be used for checking if N is one of the years in which contest was hosted.

Editorialist’s rant: Few of my friends said that they like short and to the point editorials. Here you go! xD

Time Complexity

Time complexity is O(1) per test case.

AUTHOR’S AND TESTER’S SOLUTIONS:

Setter’s solution
Tester’s solution
Editorialist’s solution

Feel free to Share your approach, If it differs. Suggestions are always welcomed. :slight_smile:

I thought its even more neat to use sets. Just loop through all years and insert them in the set. Then we can check if a year is good or not in o(logn).

I dont like your short editorials @taran_1407 please make longer ones as they are more informative and I get to learn something from them :frowning:

I dont like your short editorials @taran_1407 please make longer ones

The crux of the story is, that length (of editorials!) really does matter. :slight_smile:

1 Like

SUPER QUICK EXPLANATION
Explanation is even quicker. xD

On a serious note, It is extremely trivial problem even for beginners.

This is not even problem, this is just like solution :stuck_out_tongue:

That’s why a short editorial :smiley:

Is this solution correct?
#include<stdio.h>
int main()
{
int N;
printf(“Enter to verify if SnackDown was hosted in a given year\n”);
scanf("%d",&N);

switch (N)
{
	   case 2010 :
	   	printf("HOSTED");
	   	break;
	   	
	   case 2011 :
	   	printf("NOT HOSTED");
	   	break;
	   	
	   case 2012 :
	   	printf("NOT HOSTED");
	   	break;
	   	
	   	case 2013 :
	   		printf("NOT HOSTED");
	   		break;
	   		
	   		case 2014 :
	   			printf("NOT HOSTED");
	   			break;
	   			
	   			case 2015 :
	   				printf("HOSTED");
	   				break;
	   				
	   				case 2016 :
	   					printf("HOSTED");
	   					break;
	   					
	   					case 2017 :
	   						printf("HOSTED");
	   						break;
	   						
	   						case 2018 :
	   							printf("NOT HOSTED");
	   							break;
	   							
	   							case 2019 :
	   								printf("HOSTED");
	   								break;
	   								
	   								
	   									
}

}

Remove the print statement asking to input year. Second thing, handle multiple cases.

See input format of problem.