Please read the new rule regarding the restriction on the use of AI tools. ×

tiger2005's blog

By tiger2005, history, 2 months ago, In English

You can refer to the first introduction post here.

During the summer holiday, yzy1 has implemented several features for CPLib, the majority of which are designed to improve the compatibility with well-known testing systems.

CPLib Initializers

If you need to use CPLib on an evaluation platform that does not natively support it, the best way to use it is to implement a custom initializer. The initializer needs to do three things:

  1. Read and parse the command line arguments.
  2. Set up the input/output streams and the Reader variable required by the program.
  3. Set up the reporter.

We're maintaining a set of initializers for mainstream platforms. Please refer to the GitHub repository. To implement a initializer yourself, you only need to inherit few classes and implement their member functions. Visit the documentary for detailed information.

Below are platforms that we have checked the compatibility and implemented the initializers.

Platform Checker Interactor Validator Note
Arbiter (on NOI Linux 2.0) arbiter N/A N/A
CCR-Plus ccr N/A N/A
CMS cms cms N/A interactor is only available when communication_num_processes=1
CodeChef spoj spoj N/A
Codeforces Polygon testlib testlib-two-step¹ testlib percent_mode=true, enable "Treat points from checker as a percent" in test settings
DMOJ coci coci N/A use "bridged" checker or interactor (aka "grader") with type "coci"
DOMJudge kattis kattis N/A
HelloJudge hello_judge N/A N/A
HustOJ hustoj N/A N/A
Hydro testlib testlib testlib percent_mode=false²
Lemon (LemonLime) lemon N/A N/A
Lyrio (LibreOJ) testlib testlib N/A percent_mode=true
Nowcoder nowcoder N/A N/A
QDUOJ qduoj N/A N/A
SPOJ spoj spoj N/A
SYZOJ 2³ syzoj syzoj N/A
Universal OJ testlib testlib testlib percent_mode=false

¹: You need to use testlib-interactor-two-step and testlib-checker-two-step together. Read Testlib Two-Step Interaction Help for details.

²: Hydro accepts both 1 and 100 points as full score: When the score is <= 1, 1 is considered full score, otherwise 100 is considered full score. However, to prevent parsing errors caused by scoring less than 1 out of 100, it is recommended to set full score to 1.

³: SYZOJ 2 and Lyrio are two different platforms, and LibreOJ is no longer developed based on SYZOJ 2.

⁴: UOJ Community Edition needs to edit the source code or upgrade the compiler to get C++ 17 or higher support.

By the way, the only popular testing system that is incompatible with CPLib is Luogu, as Luogu checkers and interactors are forced to compile with C++ 14, which is lower than the C++ 17 required by CPLib.

WASM Support

With the help of WebAssembly/wasi-sdk, CPLib codes can be compiled into WASM files, which can be distributed and processed through browsers. With these WASM files, it's possible for testing systems to draw graphs based on JSON-formatted input, simulate interactive process online, automatically identify multiple test cases and so on.

You can experience some of these features on CPLib WASM Demo. You can also check the source code in yzy-1/cplib-wasm-demo.

Full text and comments »

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

By tiger2005, history, 8 months ago, In English

You can refer to the second introduction post here.

CPLib is a library written in C++ for processing test data of competitive programming problems. It helps you write clear and efficient checkers, interactors, validators, and generators. CPLib uses "variable input template" as its major feature, provides friendly feedback for humans and backends, and is working hard to reach better compatibility and efficiency.

You can get CPLib from Github Repository. The "single-header-snapshot" branch automatically updates single-header version of CPLib which is easy to use. Also, you can visit cplib.vercel.app for more information. For regex-related questions, please refer to the FAQ page.

Here is a basic example of a checker using CPLib. For more examples, visit the links above.

#include "cplib.hpp"
 
using namespace cplib;
 
CPLIB_REGISTER_CHECKER(chk);
 
void checker_main() {
  auto var_ans = var::i32("ans", -2000, 2000);
 
  int ouf_output = chk.ouf.read(var_ans);
  int ans_output = chk.ans.read(var_ans);
 
  if (ouf_output != ans_output) {
    chk.quit_wa(format("Expected %d, got %d", ans_output, ouf_output));
  }
 
  chk.quit_ac();
}

The project is mainly written by yzy1, and I, tiger2005, work on syntax designs and some tiny stuffs. The project is still under development, so feel free to make suggestions!

Full text and comments »

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

By tiger2005, history, 19 months ago, In English

( My English is poor, and the blog might be a little confusing :( )

If you use Sublime Text for competitive programming, you shouldn't miss the extension called FastOlympicCoding. You can see more from its repository. The extension will create a single file containing the test cases for each code file, and you can run it easily with a key combination.

Also, Competitive Companion is a nice extension for competitive programming website. it will parse the test cases in the current website and send it to your code editors by POST requests.

Unfortunately, FastOlympicCoding cannot link with this extension. When I tried to find out how to link them, I clicked into a repository called FastOlympicCodingHook. The extension works as following: When you right click at a file and select Listen to Competitive Companion, a local server will be started to handle the POST requests from Competitive Companion. A file of test cases will be generated by the server, and you can test your code by FastOlympicCoding.

The extension is great but not convenient for me, as I needed to do several actions to make my test cases ready. So I did some modifies to the source code and finally I succeeded in making my own FastOlympicCodingHook. The server part works the same as the original one, but after selecting a template file and a problem directory, the new extension can generate code files along with test cases files automatically.

The extension worked greatly in some coders' computers, but as I'm not good at writing python code, I'm not sure if there's any bug in the extension. I hope someone can make a better extension and make the bridge between Sublime Text and Competitive Companion stronger.

Full text and comments »

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

By tiger2005, history, 3 years ago, In English

Is Codeforces' page redirection temporary?

It does is a way to get rid of web crawlers, but it makes CF Tool unusable. If you try to do any operation in CF Tool, you can only get "Not logged in" and "cannot find csrf" message. Same things happens on "Codeforces Contest Helper" developed by myself, so I can explain why.

CF Tool fetches the website page before each operation, so that it can know if you are logged out by searching for your username in the element ".lang-chooser" (Look at the upper right corner of this page and you'll know why). Also, Codeforces uses csrf-token to verify if you are a humen. These tokens are generated randomly when you open a new Codeforces page, and they're attached to verify every request on this page. CF Tool also needs this token for further operations, so it will get the token from the website page by regex.

If you are lucky to copy the redirect page source, you can see that there is no ".lang-chooser" and "Csrf-Token" any more. Thus, CF Tool thought that you are not logged in, but when it tried to get csrf-token to log in, it cannot get csrf-token and eventually fail.

I thought that projects like CF Tool can more or less solve the problems about slow Internet. I'm from China, and I can tell that most of Chinese CP lovers need to wait for a long time if they want to check out the standing lists, view problems and submit solutions. As a way to avoid loading unnecessary resources (just like css file, js file, font file, etc.), CF Tool really helps us.

So, back to the main question, I really want to know when the page redirection can be closed. As a coder, I hopes to get lower penalties by CF Tool. As a developer, I need to test new features I've made.

Full text and comments »

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

By tiger2005, history, 4 years ago, In English

As you can see, Codeforces doesn't provide real rating, and we can only use the length of rating changes to calculate the real rating. The official blog wrote that CF rating calculator uses real rating to calculate rating changes, that is, we should get all people's real ratings to predict the rating changes. But method user.rating of Codeforces API can only get ONE account's rating changes in one attempt, so it's quite hard to do it. Hope Codeforces API can add realRating into User object :)

Full text and comments »

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

By tiger2005, history, 4 years ago, In English

The help page writes that API can return a BlogEntry object in full version, that is, the content of the blog will be returned. But when I use this method,I found that a short version of a BlogEntry is returned. So is it a feature? How can I get full blog information using API?

Full text and comments »

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