Skip to content

Commit d697d5f

Browse files
authored
Merge pull request #1420 from hotate29/fix-1413
コンテスト開始前の提出を点数計算の処理から除外する
2 parents 4bd8ed9 + af63c88 commit d697d5f

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

atcoder-problems-backend/sql-client/src/problem_info.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ impl ProblemInfoUpdater for PgPool {
2727
Ok(())
2828
}
2929

30+
/// 各問題の点数を計算して更新する。
31+
///
32+
/// ある問題への提出のうち、 __コンテスト開始後の提出__ における最も大きい得点がその問題の点数となる。
33+
///
34+
/// コンテスト開始前、writerなどが仮の点数が付けられている問題をACすることがあり、
35+
/// 仮の点数がコンテストでの正式な点数より大きかった場合には、仮の点数がAtCoder Problemsでの正式な点数とされてしまう。
36+
/// これを防ぐために、コンテスト開始前の提出は点数計算で考慮しないようにしている。
37+
///
38+
/// 「コンテスト開始前にwriterがACしているが、コンテスト開始以降に一人もACできていない」場合は点数が
39+
/// 計算されないという問題があるが、現時点ではその問題は発生していないため対応は保留されている。
3040
async fn update_problem_points(&self) -> Result<()> {
3141
sqlx::query(
3242
r"
@@ -35,6 +45,7 @@ impl ProblemInfoUpdater for PgPool {
3545
FROM submissions
3646
INNER JOIN contests ON contests.id = submissions.contest_id
3747
WHERE contests.start_epoch_second >= $1
48+
AND submissions.epoch_second >= contests.start_epoch_second
3849
AND contests.rate_change != '-'
3950
GROUP BY submissions.problem_id
4051
ON CONFLICT (problem_id) DO UPDATE

atcoder-problems-backend/sql-client/tests/test_problem_info.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async fn test_update_problem_points() {
8787
let pool = utils::initialize_and_connect_to_test_sql().await;
8888
pool.insert_contests(&[Contest {
8989
id: contest_id.to_string(),
90-
start_epoch_second: 1468670400,
90+
start_epoch_second: 1687608000, // 2023/06/24 21:00:00 JST
9191
rate_change: "All".to_string(),
9292

9393
duration_second: 0,
@@ -98,33 +98,42 @@ async fn test_update_problem_points() {
9898

9999
assert!(get_points(&pool).await.is_empty());
100100

101+
// コンテスト開始前の提出
101102
pool.update_submissions(&[Submission {
102103
id: 0,
103-
point: 0.0,
104+
point: 625.0, // コンテスト開始前にwriterが設定することがある仮の得点
104105
problem_id: problem_id.to_string(),
105106
contest_id: contest_id.to_string(),
107+
epoch_second: 1687208168, // 2023/06/20 05:56:08 JST
106108
..Default::default()
107109
}])
108110
.await
109111
.unwrap();
110-
pool.update_problem_points().await.unwrap();
111-
assert_eq!(
112-
get_points(&pool).await,
113-
vec![("problem".to_string(), Some(0.0))]
114-
);
115112

116-
pool.update_submissions(&[Submission {
117-
id: 1,
118-
point: 100.0,
119-
problem_id: problem_id.to_string(),
120-
contest_id: contest_id.to_string(),
121-
..Default::default()
122-
}])
113+
// コンテスト開始後の提出
114+
pool.update_submissions(&[
115+
Submission {
116+
id: 1,
117+
point: 100.0,
118+
problem_id: problem_id.to_string(),
119+
contest_id: contest_id.to_string(),
120+
epoch_second: 1687608000, // 2023/07/08 21:00:00 JST
121+
..Default::default()
122+
},
123+
Submission {
124+
id: 2,
125+
point: 550.0, // こっちが正式な得点
126+
problem_id: problem_id.to_string(),
127+
contest_id: contest_id.to_string(),
128+
epoch_second: 1687608000, // 2023/07/08 21:00:00 JST
129+
..Default::default()
130+
},
131+
])
123132
.await
124133
.unwrap();
125134
pool.update_problem_points().await.unwrap();
126135
assert_eq!(
127136
get_points(&pool).await,
128-
vec![("problem".to_string(), Some(100.0))]
137+
vec![("problem".to_string(), Some(550.0))]
129138
);
130139
}

0 commit comments

Comments
 (0)