87 lines
1.9 KiB
Python
87 lines
1.9 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 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
|