DBradac's blog

By DBradac, history, 8 years ago, In English

I would like to invite you to participate in the online mirror of the Croatian Olympiad in Informatics which is held this Saturday.

The problemset will consist of 3-5 IOI stlye tasks and you will have 5 hours to solve them. The expected difficulty is greater than usual COCI rounds, but lesser than IOI.

Click here to see where the coding begins in your timezone.

Full text and comments »

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

By DBradac, history, 8 years ago, In English

Join us this Saturday on the 7th round of this year's COCI!

Click to see where the coding begins in your timezone.

We can discuss the problems here after the contest.

Full text and comments »

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

By DBradac, history, 8 years ago, In English

Everyone has had a bug in their code because of accessing out of array bounds. However, in some cases, the program will run as expected.

I have two examples from today's contest: problem B — 24829988 problem C — 24831518

In both of these problems, I had stupid bugs. For problem B, it's possible that the argument k of the function is zero and this line

if (ind == f[k-1]) return (int) (n % 2)

will access f[ - 1] which is undefined.

I have found this bug, and after some stress testing locally and on CodeForces, I decided not to resubmit because it seemed fine.

Now, in problem C, I iterated up to 1029 and the value of i xor x can become larger than the size of the array. However, this is only an issue if that piece of memory is not used by the process and it will result in seg fault.

Otherwise, nothing will be changed because we add zero.

I only found this bug while I was trying to hack someone else's solution so I couldn't resubmit and I was pretty sure it was going to fail system tests because locally it resulted in seg fault for some cases.

To my surprise, both submissions were actually successful, and my F failed (but that's irrelevant to this post xD) My question is this: what do you usually do when you find a bug like this during the contest and do you stress test your solutions before submitting to prevent it?

Full text and comments »

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

By DBradac, history, 8 years ago, In English

Join us today on the 6th round of this year's COCI!

Click to see where the coding begins in your timezone.

We can discuss the problems here after the contest.

Full text and comments »

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

By DBradac, history, 8 years ago, In English

Join us this Saturday on the 5th round of this year's COCI!

Click to see where the coding begins in your timezone.

We can discuss the problems here after the contest.

Full text and comments »

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

By DBradac, history, 8 years ago, In English

Join us today on the 3rd round of this year's COCI!

Click to see where the coding begins in your timezone.

We can discuss the problems here after the contest.

Full text and comments »

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

By DBradac, history, 8 years ago, In English

Join us this Saturday on the 2nd round of this year's COCI!

Click to see where the coding begins in your timezone.

We can discuss the problems here after the contest.

Full text and comments »

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

By DBradac, history, 8 years ago, In English

Join us this Saturday on the 1st round of this year's COCI!

Click to see where the coding begins in your timezone.

We can discuss the problems here after the contest.

Full text and comments »

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

By DBradac, history, 8 years ago, In English

I encountered an unusual runtime error during today's Div 2 round on problem D. http://codeforces.net/contest/706/problem/D

I implemented a simple trie, and received runtime error on test 1. http://codeforces.net/contest/706/submission/19803196

After some more submissions, I got to this: http://codeforces.net/contest/706/submission/19805829

With a couple of custom invocations, I narrowed the problem down to function mx. Implementing it a bit differently, I got AC. http://codeforces.net/contest/706/submission/19808959

After the contest, I tried submiting my code to several other sites: SPOJ, UVa, ideone. I also ran the code locally both on Windows and Linux. Out of all of these, CodeForces was the only platform on which the program crashed.

Is there a bug in the compiler, or am I missing something?

Full text and comments »

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