mredigonda's blog

By mredigonda, history, 3 years ago, In English

Link to blog post in my website: https://mredigonda.github.io/blog/proper-form-in-competitive-programming/

1

I recently started lifting weights and exercising more, I wish I would've done that while I was practicing for IOI / ICPC.

My mind kept telling me that an hour in the gym was an hour I could've spent practicing for competitions, and while that was technically correct, that didn't took into account all of the benefits from exercising, not only to my health but also directly to my performance in competitions.

One important aspect that I think would've benefitted me from exercising more is the analogy of exercise and problem solving. Actually, when practicing for competitive programming competitions, I even call it "training" too.

Not all of the analogies will match perfectly, but I find it interesting to analyze them.

There are the straightforward analogies about challenging yourself. While these are kind of trivial, they can be useful to someone.

For example, the common advice is "practice practice practice", but in the gym, if you "practice practice practice" with the same weights every time, you will have a hard time trying to lift heavier weights.

The same is true for problem solving, if you always solve problems, say, with 1800 rating points on Codeforces, you won't be able to easily solve problems with rating 2300.

So you not only need to practice practice practice, but do so with problems that challenge you enough so that you learn new things, or improve the confidence on already existing knowledge / speed. Something similar is explained in The 'science' of training in competitive programming.


2

I have a less obvious analogy.

When you are lifting weights, it's extremely important that you do so with a proper form. Not only this is needed to avoid injury, but it's also important to make the exercise you are doing, target the exact muscle you are trying to build.

Some exercises are about moving something from position A to position B, but the way you do it is what matters. If you lack mind-muscle connection, it's common that you compensate using much more your, say, biceps and forearms, than using the exact muscle you are trying to train, say, your lats or traps.

One might think that is capable of lifting, 65kg in a certain exercise, but reality might indicate that he can only do so properly with at most, 40kg. Between training 65kg improperly, or lifting 40kg properly, I always prefer the proper option, to avoid injury, but also to more efficiently target the muscles I want to build.

Now how this relates to competitive programming?

I remember when I was practicing for ICPC World Finals, I used to practice with hard problems. Eventually, after about 2 hours of trying, I was able to get a solution.

My solutions to many problems have a certain common pattern, they are usually overkills. Yes, they work, but there is usually a clever idea that would turn an hour of coding into ten minutes.

What's worse is that I felt succeeded after the problem was done, and the accepted verdict was given.

My conjecture is that by reducing the difficulty of the problems I was solving a bit, and making a stronger effort to really understand solutions and clever ideas to problems, even when I already solved them "my way", then practicing those ideas until they become fully automatic, I would've had a much better performance my competitions.

I suggest you to exercise, and learn about it, even while heavily training for competitions.

Full text and comments »

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

By mredigonda, history, 5 years ago, In English

Hi, I will be helping in a Training Camp soon, we are going to use vjudge to use problems from various OJs like Codeforces, AtCoder, SPOJ, etc., and I noticed that there doesn't seem to exist a tool to transform problem statements into PDFs (which is really useful if you are trying to compose a problemset), the ones that exist are usually specifically tailored to a single platform, and some have problems with images, etc.

So I composed some quick and dirty (but simple) solutions, this is not a tool, but with enough effort it could be converted into one. This is the Github repo if you want to read it with Github's markdown, or if you want to contribute something. I will (almost) mirror what's the repo in this post, so you don't have to bother with that extra click.

Also, if you know a better tool, I would be glad to hear that I wasted my time because this is already done, so please tell me.

How to use

Go to the problem page, open the developer tools (F12 in Chrome), go to console, and paste the respective payload below, this will allow you to print the problem statement (you can then select to print it to PDF). All of these preserve images.

These codes delete the prefix letter of the problem since they might cause users to guess the difficulty of the problem, to make this completely effective, make sure to turn off priting "headers and footers".

AtCoder

var x = document.getElementById('main-container').children[0].children[1].children[0].innerHTML;
var y = document.getElementById('task-statement').children[0].children[1];
y.removeChild(y.children[0]);
document.body.innerHTML = '<h1>' + x.substr(x.indexOf('-') + 2) + '</h1>' + y.innerHTML;
window.print();

Codeforces

var x = document.getElementById('pageContent');
var y = x.children[2].children[0].children[0].children[0].children[0].innerHTML;
x.children[2].children[0].children[0].children[0].children[0].innerHTML = y.substr(y.indexOf('.') + 2);
document.body.innerHTML = x.innerHTML;
window.print();

SPOJ

var x = document.getElementById('problem-name').innerHTML;
var y = document.getElementById('problem-body').innerHTML;
document.body.innerHTML = '<h1>' + x + '</h1>' + y; 
window.print();

Problems

  • For SPOJ and AtCoder, it doesn't report the time and memory limits, since I'm planning on using vjudge, and that tells you those limits, I plan on getting people watch the limits from there, but you get the idea of how to extend this if you want to, I would, of course, welcome PRs.

  • I need support for other OJs, feel free to add yours.

Full text and comments »

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

By mredigonda, history, 7 years ago, In English

EDIT: Never mind, I found it. Yet the number on the problemset page (250) does not match the number of the contest (247).

Hello,

Currently it's not possible to submit solutions to problems of this contest, although we can see the statements. These problems do not appear in the problemset page neither.

Is this supposed to happen? :(

Full text and comments »

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

By mredigonda, history, 8 years ago, In English

There is a publication in this facebook page:

"Hello! We have some bad news. :( Visa-free regime will not be introduced. Sincerely apologize. It is not the fault of the Organizing Committee. On Monday we will publish the procedure for obtaining a visa. We ask you in the registration system to indicate the full address of the Consulate or visa centre where you intend to obtain a visa."

I think it's the official facebook page, since when I click on the facebook icon in this website it redirects me to that facebook page.

But there's no publication already about how to obtain the visa. I post this because I think that not everyone is aware of this, and I think it's very important.

Full text and comments »

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

By mredigonda, history, 9 years ago, In English

Hello Codeforces Community!

Some of you may remember that last year there was an online mirror of Lithuanian Olympiads in Informatics, from March 20th (practice session) to March 22th.

I really liked this contest, and I'd like to know if it is also going to be held this year, so if any of you know something about this, please tell me :) Thanks!

Full text and comments »

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

By mredigonda, 10 years ago, In English

Hello, i'm an OI contestant and recently I found a lot of problems like this one:

You have a n by n matrix, each cell is either 0 or 1. Find the maximum subsquare in which all the cells are 1.

This is the classic problem, but there are a lot of variants: find the maximum rectangle, find the maximum area of two consecutive subsquares, etc.

I know a solution in O(n^3) and I know there is a solution in O(n^2) but I can't understand it, can you please explain me how it works? or give me some resource to read about it?

Also I have a particular interest in "find the maximum area of two consecutive subsquares".

It'd be great if you can help me, thanks!

Full text and comments »

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