Skip to content

Implement time complexity-based scoring with cascading closure#7

Draft
Copilot wants to merge 6 commits intocopilot/improve-leaderboard-scoring-systemfrom
copilot/fix-scoring-system-behavior
Draft

Implement time complexity-based scoring with cascading closure#7
Copilot wants to merge 6 commits intocopilot/improve-leaderboard-scoring-systemfrom
copilot/fix-scoring-system-behavior

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 31, 2025

Scoring now awards points only for the first submission at each time complexity level. When a complexity is solved, that level and all easier complexities are closed from future scoring.

Changes

Database Schema

  • Added ProblemComplexitySolve table with unique constraint on (problem_id, complexity) to track first solver per complexity level
  • Added execution_times and detected_complexity to Submission model
  • Added optimal_complexity to Problem model

Complexity Management (bemo/complexity.py)

  • Defined hierarchy: O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(n³) < O(2^n) < O(n!)
  • is_complexity_open_for_scoring() checks if complexity already solved or closed by easier solution
  • record_complexity_solve() atomically records first solver via database constraint
  • calculate_complexity_bonus() awards scaled points (O(1)=8×, O(n)=6×, O(n²)=4×)

Scoring Logic (bemo/routes.py)

  • Capture execution times from Judge0 API during submission check
  • Estimate complexity from execution time and problem rating
  • Award bonus only if record_complexity_solve() succeeds (handles races)
  • Store detected complexity in submission for display

UI

  • Problem page displays open/closed status for all complexity levels with color-coded badges
  • Submission page shows detected complexity and whether bonus was awarded

Example

Problem (rating 1000): All complexities initially open

Alice solves O(n²) → +400 bonus, closes [O(n²), O(n³), O(2^n), O(n!)]
Bob solves O(n) → +600 bonus, closes [O(n), O(log n), O(1)]
Carol solves O(n²) → 0 bonus (already solved)
Dave solves O(n log n) → +500 bonus (still open between O(n) and O(n²))

Migration

python migrate_complexity_tracking.py

Adds new fields and tables. Idempotent, backward compatible.

Original prompt

Pull Request: #5 address the feedback
The scoring system should only apply to the first submission of an open time complexity. Once a time complexity is solves, it and all easier complexities are closed from scoring.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits December 31, 2025 20:16
Co-authored-by: kushb007 <26575576+kushb007@users.noreply.github.com>
Co-authored-by: kushb007 <26575576+kushb007@users.noreply.github.com>
Co-authored-by: kushb007 <26575576+kushb007@users.noreply.github.com>
Co-authored-by: kushb007 <26575576+kushb007@users.noreply.github.com>
Co-authored-by: kushb007 <26575576+kushb007@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix scoring system to apply only on first submission of open complexities Implement time complexity-based scoring with cascading closure Dec 31, 2025
Copilot AI requested a review from kushb007 December 31, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants