Ultimate guide to TopCoder plugins

Revision en2, by Swistakk, 2018-08-16 19:46:14

Hi, I wanted to present to you guide on how you should set up TopCoder Arena in order to make competing in TC much more pleasant experience. Or at least guide how to do the same thing as I did which seem very comfortable to me compared to this big pain of competing in bare default Arena. In case you want to grab easy upvotes please leave here some joke about how I am jealous about Radewoosh getting insane boost in his contribution by writing his blogs, but the real reason is that I screwed my setup recently and needed to go through this painful and magical setup once again and it seems this information is very nontrivial and not available publicly in a known place (which I believe is one of reasons TopCoder is losing its popularity, but I hope thanks to this post I can give slight boost to it by settling up Arena problems once and for all for many people), so I wanted to share it with others. I want to express my sincere thanks to tomasz.kociumaka for guiding me by hand in this process (twice), because I would never be able to do this on my own. By the way, I use Linux, obviously. Probably many steps are also similar on Windows or Mac, but I'll leave any hypothetically needed changes up to you.


Plugins I use are CodeProcessor, FileEdit, moj and pq. Overall functionality they offer me is:

1) When I open a problem statement they create a new file corresponding to this task in a designated location.

2) This file contains template code I used, created class for me with already correctly declared method I need to fill in and namespace with samples which are then executed in main.

3) After I end coding I am able to compile my program locally (with my own debugging flags), run it and get automated feedback about its speed and correctness. This is done by moj plugin.

4) I have a simple way of adding my own sample testcases.

5) When I'm ready to submit I need to hit "Compile" button in arena and then "Submit".


So let's go to the point of how we should go about setting this up:

1) Go to this page https://www.dropbox.com/s/375tyunr3y0bb0k/TCplugins.zip?dl=0, download this zip and extract it in your fapfolder. I will denote path to this extracted folder as /path/TCplugins

2) Go to Arena, log in and go to Options->Editor->Add and fill this accordingly:

Name: CodeProcessor
EntryPoint: codeprocessor.EntryPoint
ClassPath: Add 4 paths here, to CodeProcessor.jar, FileEdit.jar, moj.jar and pq.jar (I've done this by multichoice with held Ctrl). After this it should look like /path/TCplugins/pq.jar:/path/TCplugins/moj.jar:/path/TCplugins/FileEdit.jar:/path/TCplugins/CodeProcessor.jar

save this and tick boxes next to newly added line (and maybe uncheck others if you have any ticks elsewhere)

3) Click on this newly added line and click "Configure". New big window will pop up. Fill Editor EntryPoint as fileedit.EntryPoint . Next to "CodeProcessor Scripts (...)" hit "Add" and add two entries "moj.moj" and "pq.MyPostProcessor".

4) Hit "Configure" next to Editor EntryPoint and specify path where your codes will be appearing (do not use "~" in your path, it doesn't work, you probably want to use something like /home/anon/something). Uncheck this very stupid option "Backup existing file then overwrite". Go to "Code template" and if you use C++ then modify your template to something like this (filling out parts within underscores): https://www.dropbox.com/s/63unh4paj1k4o1k/TopCoderTemplate.txt?dl=0 (I wanted to paste it here, but my attempts to correctly display dollar sign were futile, if you know a good way to do this, please message me). If you happen to use hack like "#define int long long" then also put "#undef int" before line with method declaration and "#define int long long" after it.

5) Restart you Arena and you are ready to go! Go to some practice room and do Div2 250 to familiarize with workflow with all these newly added plugins.


A few technical notes I would like to point out:

1) If I'm not mistaken on TopCoder your program is executed many times — once per every testcase. However locally your program is executed one time and it does many calls to specified method. It may seem like there is no difference, but there is a significant one — state of your global variables. You may leave your global variables in some random state and it will not affect execution of your program on testing servers, but it can affect behaviour of your program locally and you may get local WAs even though your program would be considered correct by TC. However I very rarely use global variables in TopCoder because only reason I can think of right now for using them is that when declared globally instead of putting them as attributes of my class, they are zeroed by default (which disappears if you want to be able to test your program locally, because you need to clean them anyway).

2) If you did some defines it may affect your remote compilation on server. Your code is somehow included in testing framework and this code TC adds to your code in order to grade your solution uses some variable names etc. too. It is unlikely that something like "#define SZ(x) (x).size()" will affect compilation on server, but "#define int long long" will very likely do so. That's why if you use some common expressions in defines, you better undef them (like "#undef int") at the end of your code, because otherwise you will get compilation errors when submitting even though your program compiles locally and it will be very confusing.

3) Apparently, informations about this setup are stored in ~/contestapplet.conf file. You can save a copy of it in some safe place (so that you can restore it whenever you do some mess or change your laptop) and be aware to not move this file around (that's how I screwed up my setup recently, because I cleaned my home directory of some weirdly looking files).

4) When testing locally, what is performed in order to check correctness of your code is to do some simple diff (it takes appropriate care when there are doubles in output, so don't worry about them). Be aware that problems with multiple allowed outputs exist and in such cases local testing tool will say that you FAILED, so in such cases you will need to validate your output by yourself (or use "Batch test"). But that is the same as in every other platform (unless we are provided some checker, but we are never provided, so yeah). Be aware that in such cases you should use option "Batch test" in arena which checks correctness of your output (but look at field "Correct example", not "Success")

5) Sometimes expected output is an empty vector. Code attached for testing on samples doesn't compile when expected output is an empty vector (in cpp), so you need to manually adjust that. For example by changing expected answer to {-1} and checking correctness by verifying that all your failed sample cases look like:
Received: { }
Expected: {-1}

Tags topcoder, arena, guide, plugins, codeprocessor, fileedit, moj, pq


  Rev. Lang. By When Δ Comment
en3 English Swistakk 2019-06-05 00:44:43 88
en2 English Swistakk 2018-08-16 19:46:14 157
en1 English Swistakk 2018-08-16 19:34:18 7232 Initial revision (published)