neeyanthkvk's blog

By neeyanthkvk, history, 6 years ago, In English

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!

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

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

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.

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

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

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

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.