Блог пользователя hulk_baba

Автор hulk_baba, история, 8 лет назад, По-английски

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

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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.

»
17 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Please help me find the bug in this part of the code for the problem : https://codeforces.me/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++;
        // }
    }