Enchom's blog

By Enchom, history, 8 years ago, In English

Hello everybody,

I've been practicing for a while now with some old competitions and, as you know, many of them are not uploaded on any online judge so you have to test your solutions by yourself. For this purpose I use Codeforces Gym and prepare the problems in Polygon. The trouble comes from the fact that not all of the competitions provide model solutions. Most of them give the test data, but it is in the form of input-output files and from what I've managed to understand — Polygon wants a model solution to generate output files.

My question is : Is there a way to prepare a problem in Polygon by manually uploading the correct outputs of the tests and having no model solution?

Thanks in advance!

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

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

Unfortunately no. If inputs and outputs are small, you can just hardcore them into a model solution, if not... well, you can write a model solution as an exercise.

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

    Ah that's sad. And well, the idea is to test my solution versus the correct outputs. So writing the model solution myself wouldn't make sense. Thanks for the quick response.

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

      If you are only willing to test your solution then the easiest way is to do that locally, it takes one line in bash or cmd to do so.

    • »
      »
      »
      8 years ago, # ^ |
      Rev. 2   Vote: I like it +5 Vote: I do not like it

      You may use spoj or hackerrank, they are good for this purpose.

»
8 years ago, # |
Rev. 3   Vote: I like it -9 Vote: I do not like it

Well, you could always write a small script that would read some few lines of input and compare the variables to the input and print the answer. Of course, this is not very efficient but you can do it.

Example: Input is N, M, you could just write something like

if(n == X && m == Y) print Z

A way to simplify this a lot would be to make add a unique identifier to the beginning of the test which your solution could ignore. Example, start input1.in file with the string "IN1". This string could be read by checker program which would print corresponding output. Writing a script to write this program for you is also quite straightforward.

  • »
    »
    8 years ago, # ^ |
    Rev. 2   Vote: I like it +4 Vote: I do not like it

    Yes, that's a good idea for small outputs. Unfortunately for larger outputs the model solution would end up being like 10MB+ and I doubt that Polygon would accept it.

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it -19 Vote: I do not like it

      Well, as I said, just add a unique identifier to each of the test cases, and you just identify the input in your code using that, making code length much lesser..

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

        Yeah, we will know what test is it. But how can we understand what to output?

»
8 years ago, # |
  Vote: I like it +127 Vote: I do not like it

You can locally add outputs to the end of inputs. Model solution will read (skip) input and then read-and-write output. You are practising so you will not use this hack during the contest.

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

    That's actually very clever and will work. Thanks a lot!

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

      You are welcome :)

      It will not work with problems where you should read until EOF. I think you can fix it by adding some special character to mark the end of the input (and then writing the output).