1use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6#[derive(Deserialize, Serialize, Clone, Debug)]
8pub struct ProblemConfig {
9 pub owner_id: Option<i64>,
11 pub r#type: ProblemType,
13 pub merge_subgroups: bool,
15 pub contest_id: i64,
17 pub problem_index: i64,
19 pub name_ru: String,
21 pub name_en: String,
23 pub time_limit_ms: i32,
25 pub memory_limit_mb: i32,
27 pub checker_path: String,
29 pub tests_path: String,
31 pub subgroups: Vec<Subgroup>,
33}
34
35#[derive(Deserialize, Serialize, Clone, Debug)]
37#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
38pub struct PublicProblemConfig {
39 pub id: i64,
41 pub owner_id: Option<i64>,
43 pub r#type: ProblemType,
45 pub merge_subgroups: bool,
47 pub contest_id: i64,
49 pub problem_index: i64,
51 pub name_ru: String,
53 pub name_en: String,
55 pub time_limit_ms: i32,
57 pub memory_limit_mb: i32,
59 pub subgroups: Vec<Subgroup>,
61}
62
63#[derive(Deserialize, Serialize, Debug, Clone)]
65#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
66#[cfg_attr(
67 feature = "sqlx",
68 sqlx(type_name = "problem_type", rename_all = "snake_case")
69)]
70#[serde(rename_all = "snake_case")]
71pub enum ProblemType {
72 Default,
74 Interactive,
76 RunTwice,
78 RunTwiceInteractive,
80 RunTwiceFirstInteractive,
82 RunTwiceSecondInteractive,
84}
85
86#[derive(Deserialize, Serialize, Debug, Clone)]
88#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
89pub struct Subgroup {
90 pub r#type: SubgroupType,
92 pub tests: Vec<i32>,
94 pub score: Option<i32>,
96 pub score_per_test: Option<i32>,
98 pub depends_on: Vec<usize>,
101}
102
103#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
105#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
106#[cfg_attr(
107 feature = "sqlx",
108 sqlx(type_name = "subgroup_type", rename_all = "snake_case")
109)]
110#[serde(rename_all = "snake_case")]
111pub enum SubgroupType {
112 Sample,
114 Main,
116}
117
118#[derive(Clone, Debug, Serialize, Deserialize)]
120pub struct ProblemQuestionRequest {
121 pub title: String,
123 pub text: String,
125 pub created_at: DateTime<Utc>,
127}
128
129#[derive(Deserialize, Serialize, Clone, Debug)]
131#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
132pub struct ProblemQuestion {
133 pub id: i64,
135 pub owner_id: i64,
137 pub problem_id: i64,
139 pub title: String,
141 pub text: String,
143 pub answer: String,
145 pub created_at: DateTime<Utc>,
147}