Moj plugin for participating in TopCoder SRM

    Introduction


    People who are fond of sports programming are well aware of TopCoder's competition. Among them, perhaps the most popular form is Single Round Match, or SRM. The scheme of SRMs is quite specific, and in some ways unique. In short - first, participants solve 3 problems of different difficulty levels, then for some time they look for mistakes from opponents, getting extra points for this.

    To organize such competitions, TopCoder created a Java applet (TopCoder Arena). There were also craftsmen who wrote plugins for this very arena to make life easier for themselves and others. But installing the latter often causes difficulties for novice SRM's. It was this problem that became the motive for writing this article.


    Where to begin?


    You always need to start from the very beginning, in this case, from the installation of the arena. As mentioned earlier, the arena is a Java applet. Therefore, the first thing we need is the Java Runtime Environment (JRE) + Java Web Start (JWS), which come in one package.

    Java installation

    Step 1. To download Java, go to www.java.com/en/download/manual.jsp . Select the desired installation file from the list:


    Step 2. Install Java. The necessary components will be automatically installed on your computer, namely JRE + JWS:




    Install TopCoder Arena

    Step 3. Visit www.topcoder.com/tc .


    In the future, on the same site you will be able to look into the events calendar (“Events calendar”), check the rating, take part in discussions on the forum and much more. Right now we need an arena. In the menu on the left, select "Competitions" - "Algorithm" - "Single Round Matches (SRM)" - "Launch Arena", after which you will see something like this:


    Note 1. Yes, it says that I have JWS installed, but on in fact, this is not so. It’s just that it’s not installed as a separate component, but comes in the Java package with everything else.
    Note 2. User Nicolettenoticed that after pressing “Launch Arena” the window with the red button may not open. Instead, she said, the download of “ContestAppletProd.jnlp” will begin immediately. Well, in the end, it is the downloading of this file that is the main goal at this step. Do not be alarmed if that.


    Click on the big red button and you will be offered to download the file “ContestAppletProd.jnlp”. This is the same Java applet. Download and run, as a result you will see a welcome window:


    Here I suggest you to register if you are a new user.
    Congratulations, the arena is set. Our next task is to install and configure the Moj plugin.

    Install and configure Moj plugin


    Step 4. Download the Moj plugin files. You can find them, for example, on the TopCoder forum:
    apps.topcoder.com/forums/;jsessionid=84612D3FBAD554FF37DD381DD857BC20?module=Thread&threadID=597911&start=0&mc=60
    or download directly from here:
    github.com/downloads/lovrop/topcomomo .16.zip
    Unzip the downloaded archive to any convenient folder.

    Moj Connection

    Step 5. In the arena, open the editor settings window (“Options” - “Editor”):


    As a result, you will see the window:


    Step 6. Next to the “Common ClassPath” field, click the “Browse” button. In the window that appears, go to the folder with the unpacked plugin:


    and select three * .jar files:
    • Codeprocessor.jar
    • Fileedit.jar
    • moj.jar

    Step 7. In the settings window, click the Add button. Fill the window that opens with the following values:
    • Name: Codeprocessor2.0
    • EntryPoint: codeprocessor.EntryPoint
    • ClassPath: but in step 6, select the 3 specified * .jar files.



    A new line appeared in the settings window corresponding to the installed plugin. To make it a default plugin, check the corresponding boxes “Default” and “At Startup”:


    Moj setup

    Step 8. In the settings window, select the line corresponding to Codeprocessor2.0, and click the "Configure" button. In the window that appears, click the Add button. As a result, an empty (white) line appears, in which you need to enter "moj.moj". In the “Editor EntryPoint” field, enter “fileedit.EntryPoint”.


    Step 9 . Next to the Editor EntryPoint field, click Configure. In the window that appears, in the "Enter directory to read / write problems to" field, enter the path to the folder in which the code templates will appear when opening a new task.


    In the “Code Template” tab, it is proposed to enter a code template that will be registered in the source code file. As an example, I can offer my own (if you copy-paste - do not forget to select the C ++ language first): pastebin.com/kwt4Whp3


    Step 10.Click “Save”:


    In the Codeprocessor settings window, click the “Verify” button. If everything went well and connected correctly, you should receive a message stating that all components were found:


    Again, click “Save”, receiving the following warning along the way:




    This completes the setup.

    Plugin check


    To test Moj’s capacity, select any practice room in the arena:


    In the room’s interface, in the Choose problem field, select any of the 3 tasks. By the way, there you will immediately see the number of points by which tasks are evaluated.
    Having opened the task, you will see the following window:


    This is where you can read the condition, check the Activity Log and make sure that Moj worked. For fidelity (and for training), open the code and write a solution. By the way, one of TopCoder’s features: you need to write not a whole program, but just a class. The data is supplied as arguments to the class method, the result is returned through the value of the method. Moj - appends everything (by template) that is outside the class. Thanks to this, when you run the program, you can check your code on tests from conditions that are automatically registered by Moj directly into the source file.
    When the class is ready, click “Save”, “Compile”, “Test” (optional), and “Submit”. This usually completes the writing of the code, and the decision is considered to be received (but not necessarily correct - the correctness is checked during the system test, at the end of the competition).

    Conclusion


    TopCoder competitions are significantly different from others, including the ACM standard. To study all the features that were not even mentioned here, it can take quite a lot of time. However, the main thing is to start, and experience will come with time.

    Also popular now: