116 lines
2.5 KiB
Python
116 lines
2.5 KiB
Python
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class TestCaseCreate(BaseModel):
|
|
input: str
|
|
expected_output: str
|
|
is_sample: bool = False
|
|
points: int = 0
|
|
order_index: int = 0
|
|
|
|
|
|
class BulkTestCaseImport(BaseModel):
|
|
"""
|
|
Bulk import test cases from text.
|
|
|
|
Format:
|
|
- Tests separated by test_delimiter (default: ===)
|
|
- Input and output separated by io_delimiter (default: ---)
|
|
|
|
Example:
|
|
1 2
|
|
---
|
|
3
|
|
===
|
|
5 10
|
|
---
|
|
15
|
|
"""
|
|
text: str
|
|
test_delimiter: str = "==="
|
|
io_delimiter: str = "---"
|
|
mark_first_as_sample: bool = True # Mark first N tests as samples
|
|
sample_count: int = 1 # How many tests to mark as samples
|
|
|
|
|
|
class BulkImportResult(BaseModel):
|
|
created_count: int
|
|
test_cases: list["TestCaseResponse"]
|
|
|
|
|
|
class TestCaseResponse(BaseModel):
|
|
id: int
|
|
input: str
|
|
expected_output: str
|
|
is_sample: bool
|
|
points: int
|
|
order_index: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class SampleTestResponse(BaseModel):
|
|
"""Sample test shown to participants (without expected output hidden for non-samples)"""
|
|
input: str
|
|
output: str
|
|
|
|
|
|
class ProblemCreate(BaseModel):
|
|
contest_id: int
|
|
title: str
|
|
description: str
|
|
input_format: str | None = None
|
|
output_format: str | None = None
|
|
constraints: str | None = None
|
|
time_limit_ms: int = 1000
|
|
memory_limit_kb: int = 262144
|
|
total_points: int = 100
|
|
order_index: int = 0
|
|
test_cases: list[TestCaseCreate] = []
|
|
|
|
|
|
class ProblemUpdate(BaseModel):
|
|
title: str | None = None
|
|
description: str | None = None
|
|
input_format: str | None = None
|
|
output_format: str | None = None
|
|
constraints: str | None = None
|
|
time_limit_ms: int | None = None
|
|
memory_limit_kb: int | None = None
|
|
total_points: int | None = None
|
|
order_index: int | None = None
|
|
|
|
|
|
class ProblemResponse(BaseModel):
|
|
id: int
|
|
contest_id: int
|
|
title: str
|
|
description: str
|
|
input_format: str | None
|
|
output_format: str | None
|
|
constraints: str | None
|
|
time_limit_ms: int
|
|
memory_limit_kb: int
|
|
total_points: int
|
|
order_index: int
|
|
created_at: datetime
|
|
sample_tests: list[SampleTestResponse] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class ProblemListResponse(BaseModel):
|
|
id: int
|
|
contest_id: int
|
|
title: str
|
|
total_points: int
|
|
order_index: int
|
|
time_limit_ms: int
|
|
memory_limit_kb: int
|
|
|
|
class Config:
|
|
from_attributes = True
|