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:

SUPER QUICK EXPLANATION
Explanation is even quicker. xD

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

}

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

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:

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

See input format of problem.

#include <stdio.h>

int main(void)
{
int n,y,i;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&y);
if(y==2010||y==2015||y==2016||y==2017||y==2019)
printf(ā€œHOSTEDā€);
else
printf(ā€œNOT HOSTEDā€);
}
return 0;
}

but its showing error

Your inverted commas in printf are intaliced.
Edit this and your code will run with no error