hulk_baba's blog

By hulk_baba, history, 7 years ago, In English

Hello CF community! I have previously asked my doubts regarding the specific problem on my blog but turns out I was getting downvoted. So, I thought there must be something I was doing wrong. I am writing this to know how to ask one's doubt regarding specific problems and their approaches? Are there some guidelines or other threads where I should ask my doubts? Any help is appreciated. Thank you

  • Vote: I like it
  • +4
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

You should follow how to ask guidelines from stackoverflow. If you are not following them this will usually result in a poor question that will be hard to understand or answer. Also you have to show your progress. If you have some error have your tried running code on your machine with the same input? If on the same input your code produces result A and codeforces your code produces results B what have you done to investigate why it happens? If you write a good question and show your progress I don't think that you will get downvoted.

»
11 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Please help me find the bug in this part of the code for the problem : https://codeforces.com/contest/1843/problem/E

In the following code segment , I was trying to fill up an array with distinct values so after every cin I used to check if the same element had occured previously . When I submitted my code without commenting this out it was givng wrong answer verdict and when I commented it out then it got accepted. Instead of wrong answer if TLE would have come then it would be more acceptable . Please help me understand what is the problem with the below code segment .

struct segment { int l; int r; };

struct segment temp; arr=(struct segment *)malloc((m+2)*sizeof(struct segment));

for(int i=1;i<=m;i++)
    {
        std::cin>>temp.l>>temp.r;
        int j;
        // for(j=1;j<i;j++)
        // {
        //     if((temp.l==arr[j].l)&&(temp.r==arr[j].r))
        //     {
        //         break;
        //     }
        // }
        // if(j==i)
        // {
            arr[size+1].l=temp.l;
            arr[size+1].r=temp.r;
            size++;
        // }
    }