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.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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".
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
So let's go to the point of how we should go about setting this up:
1) Go to this page https://www.mimuw.edu.pl/~wn341489/TCplugins.zip, 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.mimuw.edu.pl/~wn341489/TopCoderTemplate.txt (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.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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}
[insert joke about how Swistakk is jealous about Radewoosh getting insane boost in his contribution by writing his blogs]
LMAO. [insert joke about how aryaman.arora2020 is trying to troll lgms because he wants to seek attention.]
I feel like LanceTheDragonTrainer writes comments with sense recently, and he still gets downvotes just as a tradition xd
Regarding the blog: That's a lot of work, what suggests that TC platform is bad :( I wonder what are the rules of TCO. Do they allow participants to bring their own laptops? Or to have half an hour before the competition to configure everything?
Maybe it's possible to compare doubles with an allowed error by default in your configuration? They appear quite often in TC, so a change like that would be useful. That being said, I'm not going to use your tools because IMO it doesn't hurt that much to type in arena and then copy to my IDE if the code doesn't work and is complicated.
They allow participants to bring their own laptops.
Plugins take care of comparing doubles, what they don't handle is "any valid solution will be accepted" problems, in which case you will have to use the Arena checker (the one that says "success, correct answer: false", which has obviously never confused anyone :P)
I can confirm that your item 1) is correct.
And regarding 2), if people use ugly hacks like "#define int long long", they fully deserve it if it sometimes comes back to bite them :)
What is wrong with #define int long long and #define abs llabs sir?
I used them all the time and never got WA even once. What prob does it have?
I used #define int long long and got TLE/MLE once :(. The problem disappeared when I used long long only when I need to use it.
"#define abs llabs" sounds really silly. abs in std already works for ll.
what about using fabs? ;p
Answering to Necrozma: You use more memory and sometimes more time. When you must use ints (e.g. you know a program doesn't fit in the memory), you are not used to catching places where LL is needed. The same when you want to write in a different language or you want to write a production code in a company. And it's trickier to solve problems where you should implement a function with some given format.
Regarding item 1), I have the following code instead of the DEFAULTMAIN in my template:
What it does is run every testcase as a separate process, with the test number passed as command line argument. You can also run a single case via e.g.
./yourexecutable 3
to run 3rd case.I believe the credits go mainly to marek.cygan as I found the process spawning scheme on his webpage and added some modifications (IIRC the display of summary is mine).
It doesn't come as a surprise to me that this code may be authored by marek.cygan :P. If you look at their team library it's full of ugly global variables etc xD.
Or, if you program in Java, just use CHelper and it will do everything out of the box
I am new on Topcoder, and I can't even login in arena applet. There is a message that saying "A connection to the server could not be established". What am I missing?
where is this Options->Editor->Add in topcoder arena
https://arena.topcoder.com/#/u/dashboard
The tutorial applies to the Java Arena applet only.
I doubt there are any Web Arena plugins at the moment... -,-
If anyone is wondering how to include the test code in the template here is my template
What does pq plugin do? My usual setup includes only codeprocessor, fileedit and moj and I can't really notice the difference.
I don't know xD. I guess I was given full package when I was taught this and didn't delve into details of what every each of them does.
As far as I can see the pq plugin removes unused define's, const's and typedef's if they are never used. This enables you to define many of those in your header but only the used ones are uploaded in your submission. This helps to avoid the warning that you are using to much unused code in your submission.
Oh, I usually disable the unused code check. That's why I noticed no difference :D
thanks for the blog.
but links aren't working with me so if you don't have problems, please, can you upload them to another links
I have no idea why they stopped working (I hope they worked at some point, that would be sad if you were the first person to notice that xD). I reuploaded these files to a different place, I believe they should work now.
Thanks
Auto comment: topic has been updated by Swistakk (previous revision, new revision, compare).
If anyone is interested, I forked and patched the moj plugin to fix the issue from item (5), regarding the compilation error when an array is empty. With an only caveat that you'd need to use a C++11 compatible compiler, which should be the case for any modern compiler anyway.
You can download it from here.
What has changed is instead of generating code like this:
it will now generate the following:
which uses the list initialization feature from C++11.
That's great to hear as this error was really a pain sometimes!
Can you please explain how to give sample test cases and test your code locally?
I have a new machine and needed to get ready for TCO. I recorded the process of installing these plugins, and then testing them. https://youtu.be/kZ88uEkneb0
I am not able to copy-paste my template code in Code Template field in fileedit configuration on MAC OS. Anyone facing the same issue.
What is the use of
// Begin Cut here
and// End Cut here
comment?It tells plugins that this part of your local code should not be submitted to the Arena.
Has anyone been able to use KawigiEdit or any other plugin on the latest version of Mac OS?
This post is pretty recent and suggests that it is doable. https://www.topcoder.com/thrive/articles/setting-up-the-topcoder-java-applet-arena-and-kawigi-editor
However, I'm getting the following error: java.lang.InstantiationError: Cannot instantiate KawigiEdit. java.lang.ClassNotFoundException: kawigi.KawigiEdit