|
5 | 5 | use App\Config\Loader\YamlConfigLoader; |
6 | 6 | use App\DataTransferObject\ConfigurationSpecification; |
7 | 7 | use App\Entity\Configuration; |
| 8 | +use App\Entity\ContestProblem; |
8 | 9 | use App\Entity\Executable; |
9 | 10 | use App\Entity\Judging; |
| 11 | +use App\Entity\Submission; |
10 | 12 | use BackedEnum; |
11 | 13 | use Doctrine\ORM\EntityManagerInterface; |
12 | 14 | use Doctrine\ORM\NonUniqueResultException; |
@@ -395,4 +397,60 @@ public function addOptions(ConfigurationSpecification $item): ConfigurationSpeci |
395 | 397 | } |
396 | 398 | return $item; |
397 | 399 | } |
| 400 | + |
| 401 | + public function getRunConfig(ContestProblem $problem, Submission $submission, int $overshoot = 0): string |
| 402 | + { |
| 403 | + $memoryLimit = $problem->getProblem()->getMemlimit(); |
| 404 | + $outputLimit = $problem->getProblem()->getOutputlimit(); |
| 405 | + if (empty($memoryLimit)) { |
| 406 | + $memoryLimit = $this->config->get('memory_limit'); |
| 407 | + } |
| 408 | + if (empty($outputLimit)) { |
| 409 | + $outputLimit = $this->config->get('output_limit'); |
| 410 | + } |
| 411 | + $runExecutable = $this->getImmutableRunExecutable($problem); |
| 412 | + |
| 413 | + return $this->jsonEncode( |
| 414 | + [ |
| 415 | + 'time_limit' => $problem->getProblem()->getTimelimit() * $submission->getLanguage()->getTimeFactor(), |
| 416 | + 'memory_limit' => $memoryLimit, |
| 417 | + 'output_limit' => $outputLimit, |
| 418 | + 'process_limit' => $this->config->get('process_limit'), |
| 419 | + 'entry_point' => $submission->getEntryPoint(), |
| 420 | + 'pass_limit' => $problem->getProblem()->getMultipassLimit(), |
| 421 | + 'hash' => $runExecutable->getHash(), |
| 422 | + 'overshoot' => $overshoot, |
| 423 | + ] |
| 424 | + ); |
| 425 | + } |
| 426 | + |
| 427 | + public function getCompareConfig(ContestProblem $problem): string |
| 428 | + { |
| 429 | + $compareExecutable = $this->getImmutableCompareExecutable($problem); |
| 430 | + return $this->jsonEncode( |
| 431 | + [ |
| 432 | + 'script_timelimit' => $this->config->get('script_timelimit'), |
| 433 | + 'script_memory_limit' => $this->config->get('script_memory_limit'), |
| 434 | + 'script_filesize_limit' => $this->config->get('script_filesize_limit'), |
| 435 | + 'compare_args' => $problem->getProblem()->getSpecialCompareArgs(), |
| 436 | + 'combined_run_compare' => $problem->getProblem()->getCombinedRunCompare(), |
| 437 | + 'hash' => $compareExecutable->getHash(), |
| 438 | + ] |
| 439 | + ); |
| 440 | + } |
| 441 | + |
| 442 | + public function getCompileConfig(Submission $submission): string |
| 443 | + { |
| 444 | + $compileExecutable = $submission->getLanguage()->getCompileExecutable()->getImmutableExecutable(); |
| 445 | + return $this->jsonEncode( |
| 446 | + [ |
| 447 | + 'script_timelimit' => $this->config->get('script_timelimit'), |
| 448 | + 'script_memory_limit' => $this->config->get('script_memory_limit'), |
| 449 | + 'script_filesize_limit' => $this->config->get('script_filesize_limit'), |
| 450 | + 'language_extensions' => $submission->getLanguage()->getExtensions(), |
| 451 | + 'filter_compiler_files' => $submission->getLanguage()->getFilterCompilerFiles(), |
| 452 | + 'hash' => $compileExecutable->getHash(), |
| 453 | + ] |
| 454 | + ); |
| 455 | + } |
398 | 456 | } |
0 commit comments