JVirak's blog

By JVirak, history, 7 years ago, In English

Does anyone know what happened to hackerrank's week of code contests? I enjoyed them and they seem to have just stopped. It's not like there aren't enough contests/problems out there but still curious if anyone knows.

Full text and comments »

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

By JVirak, history, 8 years ago, In English

So I've been working through the A2OJ Div 2C ladder. For question 12 http://codeforces.net/problemset/problem/490/C my code seems to be running fine on my computer (at least for the three test cases given as examples) but it fails on the first test case (exactly the same as the first example) when I try to actually submit it http://codeforces.net/contest/490/submission/24563289.

It seems that for some reason it isn't picking up the answer in the loop (again, it does on my local machine) and is getting through the loop (which stops when an answer is found) and outputting "NO". Any help appreciated.

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it

By JVirak, history, 8 years ago, In English

Hey guys I had about 6 wrong submissions for this question http://codeforces.net/problemset/problem/760/B. On 4 of them I got timeout errors and 2 a wrong answer on test-cases 1. Now the contest is over I got to go over these with the test-cases visible. As usual test case 1 was the first example, which turns out to run perfectly fine on my laptop (gives right answer don't think it takes too long).

It turned out I had the same basic idea as the tutorials, figure out how many pillows it will take for Frodo to have p and then do binary search. I have no trouble believing that I made a mistake on either binary search or the number of pillows function itself (i.e. missed an edge case) which is why I kept resubmitting.

Anyway this http://codeforces.net/contest/760/submission/24047827 gives me the wrong answer on test case 1, producing 10000000 on the judge (the giant upper bound I set for my binary search). However on my home laptop it gives 2 (the correct answer). This gives me two related questions. 1. What is going on here? and 2. What does this do on other people's machines. (I'd be very grateful to anyone else willing to run it).

Also this http://codeforces.net/contest/760/submission/24048597 version of the code gives me a timeout error. Again on my local machine it manages to do the job (at least on test case 1). While I'm not sure exactly how long it takes to run (runtime output includes typing time) it seems almost instant.

Obviously I'd like to avoid this next time so if anyone can help me find this error I'd really appreciate it.

Full text and comments »

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

By JVirak, history, 8 years ago, In English

Hi All I'm getting a timeout error for this question. As far as I can tell my algorithm is the same as the one in the tutorial and it's implemented in C++ so I'm at a loss for why it's not fast enough. Moreover when I change from reading in the input to automatically generating an input the same size it takes 13ms and the question allows 1000ms/1s.

In practise I'm reading through the rows of a 1000x1000 matrix one at a time and then the columns one at a time. In my head this should be about 2 million operations (I've heard 10^9 is usually the upper limit to avoid).

My code is here http://codeforces.net/contest/738/submission/22423987. Any help would be greatly appreciated.

Jon

P.S. It seems like my code is coming out without any kind of spacing. How do I correct this?

Full text and comments »

  • Vote: I like it
  • -13
  • Vote: I do not like it