Exemple #1
0
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)
}
Exemple #2
0
func (self Format) Export(problems []*model.Problem, directory string) (err error) {
	defer SuppressPanic(&err)
	file, err := os.Create(filepath.Join(directory, "problems.xml"))
	if err != nil {
		return err
	}

	container := Container{
		Generator: Generator{
			Name: "UPC",
			Url:  "http://github.com/lanior/upc/",
		},
		Version:  "1.2",
		Problems: make([]Problem, len(problems)),
	}

	for i, problem := range problems {
		exportProblem(&container.Problems[i], problem)
	}
	utils.XmlMarshal(file, &container)
	return nil
}