You are not logged in. Please login at www.codechef.com 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

5★hemant_dhanuka
533112
accept rate: 3%


Check this one:
3
- siddharth
+ sidklmno
+ pandey
Output should be
1
sidd
and not
1
siddh
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 :)

link

answered 18 May '17, 17:18

siddharthp538's gravatar image

4★siddharthp538
2555
accept rate: 11%

edited 18 May '17, 17:24

@siddharthp538 ty bro... u nailed it

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

No problem :)

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

I believe it fails here-

Input
4
 + hackerrank
 - hackerrankz
 + ae
 - a

Output
1
hackerrankz

Expected Output
-1

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.

link

answered 18 May '17, 17:26

vijju123's gravatar image

5★vijju123 ♦♦
15.1k11857
accept rate: 18%

@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_dhanuka5★

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

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

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 ♦♦5★

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

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

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

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

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×2,287
×176
×18

question asked: 18 May '17, 16:37

question was seen: 565 times

last updated: 18 May '17, 21:56