RogueNinja's blog

By RogueNinja, history, 4 years ago, In English

Problem link

This problem is from recent Round #672 (Div. 2). I did a stupid miscalculation (-_-). One of the dimension-size of the array was supposed to be around 3200 but I assigned the size 160. But funny thing is it still got accepted (offline solve btw).

1st Submission link

Later I understood the mistake and submitted the code again which I think is correct. 2nd Submission link

Now, why 1st solution is accepted? Is this something which can be exploited again? Or am I just lucky as there's also another dimension after it which might've persisted the result without conflicting.

Full text and comments »

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

By RogueNinja, history, 7 years ago, In English

[SOLVED] .... Bug was in my code.....

Today while solving this problem I faced a strange behavior with set<>.

I made three identical submissions only with slight changes in compare function to see it's behavior.

My three submission:

verdict : AC

compare function :

bool operator < ( const data& b ) const {
    if(pos == b.pos)    {
        return num > b.num;
    }
   return pos < b.pos;
}

verdict : AC

compare function :

bool operator < ( const data& b ) const {
    if(pos == b.pos)    {
        return num < b.num;
    }
   return pos < b.pos;
}

verdict : WA

compare function :

bool operator < ( const data& b ) const {
   return pos < b.pos;
}

Now, it can be my fault but I always have used third option when I have to compare single variable and class contains multiple variables. Also, choosing this always worked out for me, but it's not the case this time.

Now, I want to know what's causing this and why using third option is wrong? Also, what I should do if I only want to compare single or multiple variables but not all variables?

Full text and comments »

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