MikeMirzayanov's blog

By MikeMirzayanov, 6 years ago, translation, In English

Hello, Codeforces.

This is a short blog to introduce you recent updates in Testlib and Polygon.

Testlib

Generate a Permutation

Now, you can easily generate a permutation with codes like this:

Code Result
vector<int> p = rnd.perm(n); Generates 0-indexed permutation of size n
vector<int> p = rnd.perm(n, 1); Generates 1-indexed permutation of size n

Function println

Now, you can easily print space-separated lines in a generator. A println uses cout, thus prefer faster method if you print huge data.

Some examples:

Code Result
println(5); Print 5 and line break
println(1, 2, 3); Print 1 2 3 (three space separated integers) and line break
println("one", "more", 5.5); Print one more 5.5 (three space separated items) and line break
vector<int> a; ...; println(a); Print vector a (separate elements with spaces) and line break
vector<int> a; ...; println(a.begin(), a.end()); Exactly the same as above
string b[5]; ...; println(b, b + 5); Print array b (separate elements with spaces) and line break

Here is the example of a generator to print a permutation:

#include "testlib.h"

using namespace std;

int main(int argc, char* argv[]) {
    registerGen(argc, argv, 1);
    
    int n = atoi(argv[1]);
    println(n);
    println(rnd.perm(n, 1));
}

Function readInts and similar

Just as a reminder. Use functions readInts/readLongs/readStrictDoubles or readTokens/readLines in a validator to read and validate a sequence of values. To read a size of an array and array itself, use:

int n = inf.readInt(1, 200000, "n");
inf.readEoln();
inf.readInts(n, 1, 1000000, "a");
inf.readEoln();
inf.readEof();

Polygon

Example Problems

I've introduced three example problems. Each Polygon user has READ-access to them. Please, use them as examples how to write a problem in Polygon. They are:

  • example-a-plus-b: simple A+B problem
  • example-almost-upper-bound: simple problem to illustrate non-standard checker (always consider to use readAnswer function like in the example), generators and stress tests
  • example-interactive-binary-search: simple interactive problem on a binary search

Other Small Fixes

  • Allow to upload files (for example, images) as a contest property/file to use them in the statements.ftl. File names should start with 'statements-'.
  • API has been improved to support general description, general tutorial, tags, test groups and points.
  • Show problem ID on the summary box (on the righmost top block).
  • Replace UTF-8 typographic characters to their ASCII equivalent (for example, replace em dash — with ---).
  • Caching issue has been fixed. Previously, it could show RJ on tests even if the reason has been fixed.

Thanks to fcspartakm for implementing most features in Polygon.

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

| Write comment?
»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

cool !

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

wow :O !

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I Use it with My Visual Studio ,I think it would be awesome if we could use it with codeforces (codeforces, Visual Studio)

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I remember of D2T3 in NOI2018(National(China) Olympiad in Informatics) when I see the word "polygon"...

»
6 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Anything for java users ?? :'(

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

The problem still exists. I tested again, using your example-a-plus-b problem. I enabled tests points, set point for each test, submitted a WA solution and it scored the maximum point.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    try to activate the checkbox "enable groups" and then appoint the first group to the first test, the second group to the second test and so on.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Fixed, will be released soon.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks for the platform Polygon and its updates. But I think there is some bug in the current version. I was creating a problem and uploaded some input files from my computer. When running the verification, the validator "wfval.exe" kept "expecting eoln" and "exiting with code 3" on a random line. I checked the line manually and found out that it was just a usual line in my input file... I have my own validator and it works fine. Why is there a werid "wfval.exe"...?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Might it be due to different line ending characters?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Please, take a look in PMs.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Fixed now. You need to update testlib.h in a problem to fix it. The easiest way is to check and uncheck back an "Auto-update" checkbox.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +12 Vote: I do not like it

      Thank you!! I updated testlib.h and my problem passed the verification just now.

»
6 years ago, # |
  Vote: I like it +5 Vote: I do not like it

MikeMirzayanov Is everything ok with the system? When I try to submit a solution on my own problem in a group, it gives a verdict "denial of judgement". In file included from check.cpp:1:0: testlib.h:2240:42: error: 'std::true_type' has not been declared static std::string vtos(const T& t, std::true_type)