CLOST - Editorial

I have never got so may wrong answers for a question as in this one.Still unable to find a test case where this fails.Please someone find a test case for me…I have matched with all the test cases of this page and all those cases works fine in my code…Link to my code:
https://www.codechef.com/viewsolution/7951755

In the column “Breaking down the partially intersecting constraints into simpler form:”
what if length of the segment [c,b] is odd?

I have to re-post it, but still the question in practice is still accepting the incorrect solutions and it gave wrong answer to my correct solution, that’s totally disappointing from the codechef…

Codechef should also not include this contest for calculating the rating coz it has an erroneous problem which gave many users including me WA during the contest and the actual in-correct solution were passed giving them AC… one way for codechef to improve and make up for their error…

my solution: HfRB24 - Online C++ Compiler & Debugging Tool - Ideone.com
Time complexity:O(N*K)

give a test case where this logic fails-

make a string of length n as ()()…() -total n chars
then if query is x,y it assigns String[x]=’(’ String[y]=’)’

can anyone tell me why am i getting sigsev error…
https://www.codechef.com/viewsolution/15954212

Why you are putting a ‘)’ at the end and ‘(’ at the beginning. It is given that only the queries are always balanced but no description about the string(original string) it can be balanced/unbalanced.

They need not check every output. Compiler can run the input queries on this number, and check if they are all balanced.

1 Like

That’s true, but then it doesn’t matter what I am giving at the end anyway. In case there was a query involving the ends, they would have been ‘(’ for the start and ‘)’ for the end anyway. And if there wasn’t, then it doesn’t matter what I am giving here.

Can you/anybody help me with a test case for which this could fail?

thanks. I always used the method
./a.out < input > output
and used diff command to check. I assumed online compilers also did that

@s1d_3: Your solution gives wrong answer for the following test case:

1

8 3

0 5

1 2

4 7

Your solution gives : (()(()() which is wrong. One correct answer could be :
(())()()

Your solution also gives wrong answer for the test case I mentioned above in reply to @s1d_3.

Your solution also gives wrong answer for the test case I mentioned above in reply to @s1d_3.

Your solution gives wrong answer for the following test case:

1

8 2

3 4

0 7

Your solution gives : ()()()() which is wrong. One correct answer could be : ()(())()

I think the test case is invalid. No correct arrangement can be made satisfying the test case. Would be surprised if you come up with a correct answer for the test case. :slight_smile:

That is an O(klogk + n*k) solution.

Your code outputs “(())” for that test case!

Y this code fails ??

while(t--)
    {
        char a[2001];
        int n,k,x,y;
        cin>>n>>k;
        a[n] = '\0';
        for(int i=0;i<k;i++)
        {
            cin>>x>>y;
            for(int j = x;j<=y;j+=2)
            {
                    a[j] = '(';
                    a[j+1] = ')';
            }
        }
        cout<<a<<endl;
    }

here is test case like
1
8 1
0 1

it contain only () and other character are only null character …how the you can print n character string in output…I think that’s It gave WA?..

leave it…i got it