Блог пользователя neeyanthkvk

Автор neeyanthkvk, история, 7 лет назад, По-английски

Hello,

I'm not sure if this has already been answered but I cannot seem to find the answer I'm looking for. I'm relatively new to polygon and am creating a contest for a local competition. I want to put some graph theory questions and have formluated the question but am unsure how to generate the test cases. I haven't found much documentation for the test case generator and I'm not sure how I can impose constraints on the problem (There must be a path between two nodes, the graph must be connected, etc.) If anyone could help me that would be great!

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

For generating test cases, what i do is run something like this locally:

srand(time(0));
for (int i=1;i<=tcCount;++i)
{
	string na=to_string(i);
	na.append(".txt");
	ofstream fout(na);
	//generate a random test case
}

For imposing constraints, you can use a validator. You can see how to use them here.

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Oh ok. So you generate random cases and use the validator to ensure they fit the problem statement? That seems like a good idea.

»
7 лет назад, # |
  Проголосовать: нравится +14 Проголосовать: не нравится

For generators with testlib refer to this blog (use Google Translation) and these examples.

Create a generator which takes command line arguments argv as parameters (as does the examples above). Upload its source in Files tab and write things like gen 10 1 > $ in the generator script in Tests tab.

It's preferred to generate tests with testlib since the random seed is automatically initialized and controllable through command line arguments, and Polygon has inbuilt support for it.