JasonMendoza2008's blog

By JasonMendoza2008, history, 5 hours ago, In English

For this problem https://codeforces.com/gym/103708/problem/G, the "proper" way to solve it is to use Multi Dimensional Ternary Search.

If I were to solve it with random search (it passes: https://codeforces.com/gym/103708/submission/274048924 — very much easily), would this be considered a valid solution? I feel like saying no would invalidate the use of string / polynomial hashing but saying yes feels very much wrong.

What is the CP community opinion on this?

Full text and comments »

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

By JasonMendoza2008, history, 6 hours ago, In English

Consider this code:

#include <stdio.h>
#include <float.h>

int main() {
    double a = 100.0;
    printf("a: %.6lf\n", a);
    return 0;
}

It should print 100.000000 right? It does on https://www.onlinegdb.com/online_c_compiler, it does on my local computer. But on codeforces: https://i.imgur.com/P2CCY7Q.png

I'm more of a Python user so maybe I'm missing something big and it's actually not a bug?

Full text and comments »

Tags gcc, bug
By JasonMendoza2008, history, 5 weeks ago, In English

I asked to get hacked because the tests of the last contest were weak and my O(n*10^6) solution had passed (https://codeforces.com/contest/1989/submission/267752822). Someone nicely hacked it (https://codeforces.com/contest/1989/hacks/1052821) — really appreciate the community btw.

I fixed the code and now it's (10^6 * log(n)) (https://codeforces.com/contest/1989/submission/267775979). To be sure I fixed the code I would LOVE to re-run that test case that got me TLE but I'm not going to ask this person again and again to hack my submissions just to make sure I managed to improve my solution.

How can I reproduce the hack? Why aren't hacks added to the test cases automatically? I thought that was the case but I think it's just for the contests with open hacks.

EDIT: well the person gave me the code to generate the hack so that's nice I don't need it anymore but it would be nice to have the possibility to get the code right?

Full text and comments »

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

By JasonMendoza2008, history, 7 months ago, In English

Coincidently I was wondering a few weeks ago why codeforces was using such an outdated version of Python (https://codeforces.com/blog/entry/122386) and now Python 3.12.1 is live. As an example of why that would be useful: https://codeforces.com/contest/356/submission/240013817 is accepted whilst the exact same solution (https://codeforces.com/contest/356/submission/233016779) was not a few months ago. Probably not the best example since PyPy was able to go through for that particular example but I thought it was worth sharing.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By JasonMendoza2008, history, 9 months ago, In English

The general consensus is that competitive programming is competitive so if you're going to choose a slower language (like Java or especially Python) you need to be ready to deal with the potential setbacks and advantages of your chosen language. It's fair to say that Codeforces isn't supposed to accommodate your language choice by increasing the time limits according to the language especially if it's a poor one that is known to be slower than something like C++. HOWEVER, Python version on codeforces is currently 3.8 (out for 4 years) and versions 3.11 and 3.12 both bring speed improvements (3.11 for a lot of stuff (https://docs.python.org/3/whatsnew/3.11.html#:~:text=Python%203.11%20is%20between%2010,See%20Faster%20CPython%20for%20details.) and 3.12 for comprehensions (https://docs.python.org/3/whatsnew/3.12.html#:~:text=This%20speeds%20up%20execution%20of%20a%20comprehension%20by%20up%20to%20two%20times.)). I know loads of people use PyPy (and it does seem to work very well, cf. https://i.imgur.com/v9iOJnw.png) but it would seem relevant to allow newer versions of Python (**I would even argue it will help lower the CPU demand on codeforces servers since both versions are known to be faster** so realistically ... why not ...).

I've just started codeforces so maybe this has been discussed before but I haven't seen any topics talking about it and i honestly don't think there'd be any drawbacks in getting a newer, faster version of Python on the website.

Full text and comments »

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