LIGHTHSE - Editorial

Hi ,can anyone tell me why my code is not running for subtask-1 although it is running for subtask-2.

https://www.codechef.com/viewsolution/8156136

I suppose there will be a lot of comments here asking for why my code didn’t passed the 1 subtask although it cleared the 2 sub task, while following the similar approach…

As a lot of solution only got their 2 sub-task cleared, while the problem can have more than 1 answers.

https://www.codechef.com/viewsolution/8166788
@admin I have solved it the same way as explained in editorial… Can u plz point out the mistake or give me some test cases where I fail…I m currently getting 85

Hey, can anyone please point out a test case that prove my solution wrong for sub-task 1.I just want to know my mistake.
https://www.codechef.com/viewsolution/8132345

hey cant we take the 2 top most points and then compare their x coordinates. And then give the respective directions SE and SW.

if(x[top2]>x[top])
    {
    	printf("%d SE\n",top+1);
    	printf("%d SW\n",top2+1);
    }
    else
    {
    	printf("%d SW\n",top+1);
    	printf("%d SE\n",top2+1);
    }

@vsp4 3NW is correct for this test case .

2 Likes

Get More Details-
pest control connaught place @ PestControlInDelhi.com is for sale | HugeDomains
pest control services in vasantkunj @ PestControlInDelhi.com is for sale | HugeDomains
pest control services in dwarka @ PestControlInDelhi.com is for sale | HugeDomains
pest control laxmi nagar @ PestControlInDelhi.com is for sale | HugeDomains
pest control services in preet vihar
@ HugeDomains.com
pest control vikaspuri @ HugeDomains.com

For people asking Why Subtask 1 WA please try the below 3 test cases. These are the cases where i got WA

1
7
0 0
-2 0
1 1
1 -1
2 0
-1 -1
-1 1

1
7
0 0
0 2
1 1
1 -1
0 -2
-1 -1
-1 1

1 7 0 5 0 -5 5 2 -5 -2 -6 3 6 -3 0 0

Please tell me what is wrong. mjOBNe - Online C++ Compiler & Debugging Tool - Ideone.com

@code01aviraj my code is showing right answer for those cases , still getting WA on subtask 1 .
link to my code CodeChef: Practical coding for everyone

@code01aviraj - Testcase is working according to the logic.

@ayushgarg1804 and @mudit1993 I think your code gives wa for the below case. Point 5 is not illuminated.
1
7
0 5
0 -5
5 2
-5 -2

  • 6 3
    6 -3
    0 0

@sarvagya3943
@drift_king
check this test case… i think many people who got 85 and not 15 fail for this type of case… For 85 , the points are far away may be so it passed… for 15 , the test cases may be a bit intelligent :stuck_out_tongue:
1
5
3 0
-3 -1
-3 -2
3 -4
0 1

i think it failed there, and many test cases of same type !

For all those who got WA in subtask1 1/ Try checking your answer when all the points lie on the same line I.e. either the x coordinate or y coordinate for all points remains constant.

Really poor test cases were set up for the question. Corner cases were included in Subtask 1 but were not included in Subtask 2. Many users got away with 85 points although there was a glitch in their approach or logic.

This should not have happened.

There is a small correction in the Editorial.

In sub task 2, the word ‘first’ set has to be changed to ‘second’ set in the 4th point.

If in the first set, there is an island such that it has the maximum y-coordinate amongst all given N islands, then we can place a lighthouse on it facing in the SW direction. This will illuminate all the islands.

to

If in the second set, there is an island such that it has the maximum y-coordinate amongst all given N islands, then we can place a lighthouse on it facing in the SW direction. This will illuminate all the islands.

2 Likes

I am convinced that there are a few missing solutions in this problem. I have tested my solution with all the tricky edge cases mentioned in the comments so far. And all of them have given the correct output so far. I am yet to come across a test case for which my solution fails. I still have no idea why my solution got 85pts only. I would be grateful if someone can come up with a test case for which my solution fails. Here’s the link : https://www.codechef.com/viewsolution/8033551

@Author: why not provide the test cases ? I think it would make the discussion easier. A lot of people seem to think there is no bug in their solution…

@admin please provide the test cases.my code only works for 3rd task of 2nd subtask.wa in rest.could anyone tell me the reaso behind it?

Could anybody point the test case for which my solution fails for sub task 1 ?? It runs fine with the cases mentioned in previous comments .
https://www.codechef.com/viewsolution/8119136