use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct ProblemConfig {
pub owner_id: Option<i64>,
pub r#type: ProblemType,
pub merge_subgroups: bool,
pub contest_id: i64,
pub problem_index: i64,
pub name_ru: String,
pub name_en: String,
pub time_limit_ms: i32,
pub memory_limit_mb: i32,
pub checker_path: String,
pub tests_path: String,
pub subgroups: Vec<Subgroup>,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
pub struct PublicProblemConfig {
pub id: i64,
pub owner_id: Option<i64>,
pub r#type: ProblemType,
pub merge_subgroups: bool,
pub contest_id: i64,
pub problem_index: i64,
pub name_ru: String,
pub name_en: String,
pub time_limit_ms: i32,
pub memory_limit_mb: i32,
pub subgroups: Vec<Subgroup>,
}
#[derive(Deserialize, Serialize, Debug, Clone)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(
feature = "sqlx",
sqlx(type_name = "problem_type", rename_all = "snake_case")
)]
#[serde(rename_all = "snake_case")]
pub enum ProblemType {
Default,
Interactive,
RunTwice,
RunTwiceInteractive,
RunTwiceFirstInteractive,
RunTwiceSecondInteractive,
}
#[derive(Deserialize, Serialize, Debug, Clone)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
pub struct Subgroup {
pub r#type: SubgroupType,
pub tests: Vec<i32>,
pub score: Option<i32>,
pub score_per_test: Option<i32>,
pub depends_on: Vec<usize>,
}
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[cfg_attr(
feature = "sqlx",
sqlx(type_name = "subgroup_type", rename_all = "snake_case")
)]
#[serde(rename_all = "snake_case")]
pub enum SubgroupType {
Sample,
Main,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ProblemQuestionRequest {
pub title: String,
pub text: String,
pub created_at: DateTime<Utc>,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
pub struct ProblemQuestion {
pub id: i64,
pub owner_id: i64,
pub problem_id: i64,
pub title: String,
pub text: String,
pub answer: String,
pub created_at: DateTime<Utc>,
}