Exemplo n.º 1
0
Arquivo: export.go Projeto: lanior/upc
func exportProblem(problem *model.Problem, helper *formats.ProblemHelper, shortName string) {
	PanicIf(helper.GenerateTestsInput("%02d.in"))
	PanicIf(helper.GenerateTestsOutput("%02d.out"))
	PanicIf(helper.GenerateSolutions("{NAME}.{EXT}"))

	file, err := helper.Archive.Create("problem.xml")
	PanicIf(err)
	defer file.Close()

	p := Problem{
		Version: "1.0",
		Id:      "upc.exported." + strings.ToLower(shortName),
		Script: Script{
			Type: "%icpc",
			Testset: Testset{
				TestCount:     len(problem.Tests),
				InputPattern:  "##.in",
				AnswerPattern: "##.out",
				InputName:     problem.InputFile,
				OutputName:    problem.OutputFile,
				TimeLimit:     fmt.Sprintf("%ds", int(problem.TimeLimit)),
				MemoryLimit:   int(problem.MemoryLimit * 1024 * 1024),
			},
			Verifier: Verifier{
				Type: "%testlib",
				Binary: Binary{
					Id:   "x86.exe.win32",
					File: "check.exe",
				},
			},
		},
	}
	utils.XmlMarshal(file, p)
}
Exemplo n.º 2
0
Arquivo: export.go Projeto: lanior/upc
func exportProblem(problem *model.Problem, helper *formats.ProblemHelper, shortName string) {
	PanicIf(helper.GenerateTestsInput("%03d.in"))
	PanicIf(helper.GenerateTestsOutput("%03d.out"))
	PanicIf(helper.GenerateSolutions("{NAME}.{EXT}"))

	data := fmt.Sprintf(ConfigTemplate, shortName, problem.Title, int(problem.TimeLimit))
	helper.Archive.WriteFile("domjudge-problem.ini", []byte(data))
}
Exemplo n.º 3
0
Arquivo: export.go Projeto: lanior/upc
func exportProblem(problem *model.Problem, helper *formats.ProblemHelper, shortName string) {
	shortName = strings.ToLower(shortName)

	testsIn := fmt.Sprintf(filepath.Join(shortName, "in", "%s%%02d.in"), shortName)
	testsOut := fmt.Sprintf(filepath.Join(shortName, "out", "%s%%02d.out"), shortName)
	programs := fmt.Sprintf(filepath.Join(shortName, "prog", "%s{ID}.{EXT}"), shortName)

	PanicIf(helper.GenerateTestsInput(testsIn))
	PanicIf(helper.GenerateTestsOutput(testsOut))
	PanicIf(helper.GenerateSolutions(programs))

	helper.Archive.MkdirAll(filepath.Join(shortName, "doc"))
	file, err := helper.Archive.Create(filepath.Join(shortName, "doc", shortName+"zad.tex"))
	PanicIf(err, "Cannot create problem description: %s", err)

	err = DescriptionTemplate.Execute(file, problem)
	PanicIf(err, "Cannot write problem description: %s", err)
	file.Close()

	for _, solution := range problem.Solutions {
		PanicIf(helper.GenerateSolution(solution, 1, strings.Replace(programs, "{ID}", "", -1)))
		break
	}
}