Get Started with TopCoder in Python (2020 Edition)

Note: When searching for TopCoder's Applet, a link to a web page called topcodr.co appears, but be aware that this is a different domain name from topcoder.com. Please give me. </ font> </ b>

Introduction

TopCoder almost always comes up when you look at books and articles on competitive programming, but it has a strong habit of system and problem sentences, and I feel that submitting one past question is a high threshold.

The other day, I participated in SRM once with Python, so I will post the basic operation method and how to prepare the environment. The points explained in this article are the following three points.

―― 1. Never use the Web version for Arena. Access Arena using the Java version. ―― 2. Access and submit SRM past questions ―― 3. Set "Editor" in Arena (Greed is used in this article)

Access Arena with Java version.

If you already have a TopCoder account, you've probably accessed a tool called Arena from "Community-> Compete-> Competitive Programming". However, the Web version is slow and the accessibility to past questions is very poor. Rather, it is useless.

https://www.topcoder.com/community/competitive-programming/how-to-compete#The%20Applet%20Arena Prepare the Java version of Arena by referring to. The procedure is as follows.

-Install Java JRE.

--Once the JRE is installed, on Windows open the control panel Java Configuration and add http://www.topcoder.com to the Security "Exception Sites". This allows the downloaded applet to run.

--From the previous page, access Link to TopCoder Java Applet. It is convenient to save this applet and keep it on your desktop. (Links may be preferable as Applets may be updated)

--Enter your TopCoder username and password to log in.

Access and submit past issues

In TopCoder, it is necessary to create an appropriate Class instead of inputting stdin like AtCoder and Codeforces. At first, it seems difficult to attach. There is no problem if you check only the flow here and proceed to the next step.

--Practice Room in Arena-> Select the past problem you want to see from SRMs
A few hours before the contest starts, you will temporarily be unable to access past SRM questions. Let's try it after the contest is over. </ font> --SRM basically consists of 3 questions. Select the problem you want to access from Coding Phase. --There will be a problem, so I will solve it. --After writing the code, execute it in the order of Compile-> Batch Test-> Submit. (Compile is also required in Python) --If you submit and pass Test, the following display will be displayed and points will be given. But don't end with. This is just that the submission has been completed, it does not check whether each Batch Test has passed, and unlike Codeforces, it does not perform a slightly stronger pre-test. --Once, close this window, move to the SRM top screen, and select Practice Option-> Run System Test. --Check the result. In the example, two System tests failed. You can check the input / output by double-clicking.

Super important: Install Python 2.7

TopCoder's Python version is 2.7. Be sure to install Python 2.7 before proceeding to the following steps. </ font> </ b>

Set Editor to greed

--Access Greed page on github. It is as in Quick Start, but it is explained below.

--Download the jar of 2.0RC from Downloads on this page. Put it in an appropriate directory.

--Select ʻOptions-> Editor-> Add` on the lobby page after logging in to Arena. Enter as follows. (For ClassPath, click Browse and select the jar downloaded in 2.) (githubより転載)

--Check Default and At Startup. Then select Configure.

--Here, enter the full path of the parent directory where the template in question will be created.

--If you access the problem in a later process, the directory for each SRM will be cut to this directory as shown in the figure below.

--In this state, open the SRM problem explained earlier. Then, the text editor was displayed at the bottom of the screen until earlier, but it becomes as follows, and it is not possible to enter the code. --In this state, if you open the folder specified by No. 5, Scissors.py and Scissors.html will be created (in this case). Refer to this HTML as a problem statement without looking at the description of Arena. The list is different, and you can copy and paste at once, which is convenient when you want to translate the whole sentence into machine translation. --The created py contains a test. In this case, code the following part of return 0 to meet the requirements.

class Scissors:
    def openingTime(self, N):
        return 0
(Below is the automatically generated code)

- Run with Python 2.7 </ font> </ b>. PASS / FAIL is displayed as shown below. Let's fix the code until all are PASS.

  Testcase #0 ... PASSED! (0.000 seconds)
  Testcase #1 ... FAILED! (0.000 seconds)
           Expected: 40
           Received: 20
  Testcase #2 ... FAILED! (0.000 seconds)
           Expected: 110
           Received: 20
Passed : 1 / 3 cases

--When all passes, do Compile-> Batch Test-> Submit in that state (the source code is saved). When you run Compile, you can see that the source code is obtained by saying Getting source code from SRM ~. (Internally, the source code up to # CUT begin is passed)

gl, hf!

Other information

--Japanese article to change template: https://minus9d.hatenablog.com/entry/2019/05/01/222914

Recommended Posts