PROTEPOI - Editorial

Can anybody post some good test cases as I have done the same thing during the contest with nlogn TC and still got the WA.I can’t figured out what’s wrong with my code
Here is my code : CodeChef: Practical coding for everyone
Thanks in advance

Hey I used similar logic,but got wrong answer would you help me?
In program i sort the segment by starting point and chooses the one segment whose starting point is valid and end point is longest
here is the link to my code: gtN4CV - Online C++ Compiler & Debugging Tool - Ideone.com

@durden8055 . Have a look at this test case, actual answer should be “2” but your code displays “-1”.

1

7 3 7

1 1 6 1

7 1 7 1

1 2 7 2

1 3 1 5

2 3 2 5

1 6 1 7

6 6 6 6

@abhi98, got the mistake, thanks !!

I also did the same thing as mentioned in the editorial. Still I was getting WA. I can’t figure out what’s wrong with my code. Can anybody provide a strong test case or debug my code please?

My solution: CodeChef: Practical coding for everyone

Thanks in advance.

@namenotfound15 Try this case. It should output 3.

Can anyone tell what’s wrong here? Tried almost all test cases. Can someone suggest a testcase for which this fails??

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

The solution links given with the editorial get directed to some error page. @admin Please look into this. Thanks ! :slight_smile:

Can someone please help me in showing where I am going wrong. Its giving WA. I have tried it with the test cases, given in the comments, by @paphonb and @abhi98. It is giving correct answers. Please help. Thanks ! :slight_smile:

Here is my code:
https://www.codechef.com/viewsolution/13893020

Can anybody please look why my code is giving Runtime (SIGABRT Error)

Link :CodeChef: Practical coding for everyone

Thanks in advance:-)

@rahulladda
check this test case.output should be 3 but your code is giving -1.
1
7 3 7
1 1 6 1
1 2 3 2
5 2 5 2
1 5 2 5
6 2 6 4
5 6 5 7
7 1 7 4

1 Like

@aniruddh48 Thanks for replying. Can you please look at the provided test case by you. There are 7 snakes given the first line of input. But it is followed by only six snakes. Please look at it. :slight_smile:

@aniruddh48 Thanks buddy. I got it what you are pointing to. :slight_smile:

@paphonb Got my mistake. Thank you so much!

Can anyone post the correct solution here.

Can anyone tell me what’s wrong in my code?? All test cases in this post had pass…
Really cannot figure out what I am missing

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

Anyone please tell what’s wrong in my code.
https://www.codechef.com/viewsolution/14060633

Ok…so, once we have the x = the leftmost point not covered, then we see all those points coveering x and having k maximum,…and then update x=k+1
but then again we will have to see traverse all the points again…this will take O(N^2).Am i right…correct me plz, if i am!

There is no need for an array. Initially, set the first uncovered point to the left endpoint of the segment you want to cover. Then, as described in the editorial, if k is the furthest right endpoint of a segment covering x, then set next x (the next point to be covered) to k+1.

It is impossible that you tried all test cases.