Roy’s Picture Hackerearth Problem Solution – Coder In Me

Roy wants to change his profile picture on Facebook. Now Facebook has some restriction over the dimension of Roy’s Picture that we can upload. It is a problem of  . Minimum dimension of the picture can be L x L, WHERE L is the length of the side of square.

Now Roy has N photos of various dimensions.
Dimension of a photo is denoted as W x H
where W – width of the photo

AND H – Height of the photo

When any photo is uploaded following events may occur on Roy’s Picture.

[1] If any of the width or height is less than L, user is prompted to upload another one. Print “UPLOAD ANOTHER” in this case.
[2] If width and height, both are large enough and
(a) when the photo is already square then it is accepted. Print “ACCEPTED” in this case.
(b) else user is prompted to crop it. Print “CROP IT” in this case.

(quotes are only for clarification)

Given L, N, W and H as input, print appropriate text as output.

Input format for Roy’s Picture-

First line contains L.
 Second line contains N, number of photos.
 Following N lines each contains two space separated integers W and H.

Output format for Roy’s Picture-

Print appropriate text for each photo in a new line.

Constraints:                                                                      1 <= L,W,H <= 10000
1 <= N <= 1000

Let a Example to think on Roy’s Picture Problem-

Here let a length of square  = 200.
Photos N = 3.
Width And Height =
500      350
200      200
150      180


Print Text According To input.

Roy's Picture


  •  When W = 500 and H = 350, It is large from L, So text is – CROP IT.
  • When W= 200 and H = 200, It is already square, So text is – ACCEPTED.
  • When W = 150 and H= 180, It is Less Than L, So text is- UPLOAD ANOTHER.

CODE For Roy’s Picture :

#include <stdio.h>

int main()

int L,N,W,H;
scanf("%d %d",&L,&N);  // Reading input from STDIN
for(int i =1; i<=N; i++)


       scanf("%d %d",&W,&H); // Reading input from STDIN
        if(W<L || H<L)
          printf("UPLOAD ANOTHER\n");

	 else if(W==H)



           printf("CROP IT\n");


	return 0;


For more Hackerearth problem solution click here

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.