You are not logged in. Please login at to post your questions!


What's wrong with my approach for WSITE01.. plz help me

problem link WSITES01

myCode Link My code is giving Correct Answer for all test cases Cheked by me but it is not passing all cases for codechef i tried a lot to found where my code is failing but dont know why plz help me

alt text

asked 18 May '17, 16:37

hemant_dhanuka's gravatar image

accept rate: 5%

Check this one:
- siddharth
+ sidklmno
+ pandey
Output should be
and not
I think what you are doing is checking whether all unblocked[i] contains the blocked[i] but along the way you also need to eliminate the strings whose unblocked[i]!=blocked[i] and only check for the remaining ones.
Hope this helps :)


answered 18 May '17, 17:18

siddharthp538's gravatar image

accept rate: 10%

edited 18 May '17, 17:24

@siddharthp538 ty bro... u nailed it

(18 May '17, 17:41) hemant_dhanuka3★

No problem :)

(18 May '17, 21:56) siddharthp5384★

I believe it fails here-

 + hackerrank
 - hackerrankz
 + ae
 - a


Expected Output

I believe that we have to include "ae" but block "a", but "a" is a prefix of "ae", so its not possible to block all bad sites without blocking a good one. So we print -1.


answered 18 May '17, 17:26

vijju123's gravatar image

4★vijju123 ♦
accept rate: 19%

@vijju123 i am sure.. u havn't submitted this question till now... output will be -1 when no filter is created... here hackerrankz filter is created so output will 1

(18 May '17, 17:40) hemant_dhanuka3★

No dear, i cross-checked it with correct programs. The output is -1.

(18 May '17, 17:44) vijju123 ♦4★

Here is what Q said-

If it is not possible to choose set of filters and satisfy all constraints, output a single line containing an integer -1.

And constraints were-

A filter is a string that should be a prefix of some blocked site, and it should not be a prefix of any unblocked site

You cannot block "a" without blocking "ae"

(18 May '17, 17:46) vijju123 ♦4★

@vijju123 okey bro... i will give another shot to problem

(18 May '17, 17:50) hemant_dhanuka3★

Yes, try giving it a shot with this in mind :)

(18 May '17, 17:52) vijju123 ♦4★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 18 May '17, 16:37

question was seen: 443 times

last updated: 18 May '17, 21:56