Skip to content

Commit

Permalink
Support wrong verdicts on ioi pcms
Browse files Browse the repository at this point in the history
  • Loading branch information
kunyavskiy committed Nov 19, 2023
1 parent a6e9448 commit 266aead
Show file tree
Hide file tree
Showing 2 changed files with 297 additions and 291 deletions.
62 changes: 34 additions & 28 deletions src/cds/src/main/kotlin/org/icpclive/cds/pcms/PCMSDataSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,49 +145,55 @@ internal class PCMSDataSource(val settings: PCMSSettings) : FullReloadContestDat
): RunInfo {
val time = element.getAttribute("time").toLong().milliseconds
val id = runIds[element.getAttribute("run-id")]
val percentage = when {
"undefined" == element.getAttribute("outcome") -> 0.0
else -> 1.0
}
val verdict = getVerdict(element)

return RunInfo(
id = id,
when (resultType) {
ContestResultType.IOI -> {
val score = element.getAttribute("score").toDouble()
val groupsScore = element.children("group").map { it.getAttribute("score").toDouble() }.toList().takeIf { it.isNotEmpty() }
IOIRunResult(
score = groupsScore ?: listOf(score),
)
when (verdict) {
null -> null
Verdict.Accepted -> {
val score = element.getAttribute("score").toDouble()
val groupsScore =
element.children("group").map { it.getAttribute("score").toDouble() }.toList()
.takeIf { it.isNotEmpty() }

IOIRunResult(score = groupsScore ?: listOf(score))
}
else -> IOIRunResult(score = emptyList(), wrongVerdict = verdict)
}
}
ContestResultType.ICPC -> {
when {
"yes" == element.getAttribute("accepted") -> Verdict.Accepted
else -> when (element.getAttribute("outcome")) {
"fail" -> Verdict.Fail
"unknown" -> null
"accepted" -> Verdict.Accepted
"compilation-error" -> Verdict.CompilationError
"wrong-answer" -> Verdict.WrongAnswer
"presentation-error" -> Verdict.PresentationError
"runtime-error" -> Verdict.RuntimeError
"time-limit-exceeded" -> Verdict.TimeLimitExceeded
"memory-limit-exceeded" -> Verdict.MemoryLimitExceeded
"output-limit-exceeded" -> Verdict.OutputLimitExceeded
"idleness-limit-exceeded" -> Verdict.IdlenessLimitExceeded
"security-violation" -> Verdict.SecurityViolation
else -> Verdict.WrongAnswer
}
}?.toRunResult()
verdict?.toRunResult()
}
},
problemId = problemId,
teamId = teamId,
percentage = percentage,
percentage = if (verdict == null) 0.0 else 1.0,
time = time,
)
}

private fun getVerdict(element: Element) = when {
"yes" == element.getAttribute("accepted") -> Verdict.Accepted
else -> when (element.getAttribute("outcome")) {
"fail" -> Verdict.Fail
"unknown" -> null
"accepted" -> Verdict.Accepted
"compilation-error" -> Verdict.CompilationError
"wrong-answer" -> Verdict.WrongAnswer
"presentation-error" -> Verdict.PresentationError
"runtime-error" -> Verdict.RuntimeError
"time-limit-exceeded" -> Verdict.TimeLimitExceeded
"memory-limit-exceeded" -> Verdict.MemoryLimitExceeded
"output-limit-exceeded" -> Verdict.OutputLimitExceeded
"idleness-limit-exceeded" -> Verdict.IdlenessLimitExceeded
"security-violation" -> Verdict.SecurityViolation
else -> Verdict.WrongAnswer
}
}

companion object {
private val logger = getLogger(PCMSDataSource::class)
}
Expand Down
Loading

0 comments on commit 266aead

Please sign in to comment.