File size: 2,586 Bytes
5fed0fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
## FrontierCS - Algorithmic Problems
### Problem Structure
Each problem in `problems/{id}/` contains:
```
problems/{id}/
βββ statement.txt # Problem description
βββ tag.txt # Category tag
βββ config.yaml # Time/memory limits, test count
βββ testdata/ # Test cases (public: 1 per problem)
β βββ 1.in
β βββ 1.ans
βββ chk.cc / interactor.cc # Checker or interactor
```
### Quick Start
#### Start Judge Server
```bash
docker-compose up --build -d # First time
docker-compose up -d # Subsequent runs
```
Judge runs at `http://localhost:8081`.
### How It Works
1. **Fetch problem** statement from judge API
2. **Generate solution** via LLM (C++ code)
3. **Submit** to judge server
4. **Poll** for result
5. **Score** based on test case pass rate
The judge sever will save solutions and their detailed judging results under the folder `algorithmic/submissions`.
### Judge API
| Endpoint | Description |
|----------|-------------|
| `GET /problems` | List all problems |
| `GET /problem/{id}/statement` | Get problem statement |
| `POST /submit` | Submit solution |
| `GET /result/{sid}` | Get submission result |
### Python API
```python
from frontier_cs import FrontierCSEvaluator
evaluator = FrontierCSEvaluator()
# Evaluate an algorithmic problem
result = evaluator.evaluate("algorithmic", problem_id=1, code=cpp_code)
print(f"Score: {result.score}")
# Get unbounded score (without clipping)
result = evaluator.evaluate("algorithmic", problem_id=1, code=cpp_code, unbounded=True)
print(f"Score (bounded): {result.score}")
if hasattr(result, 'score_unbounded'):
print(f"Score (unbounded): {result.score_unbounded}")
```
### CLI
```bash
# Evaluate a solution
frontier-eval --algorithmic 1 solution.cpp
# Get unbounded score
frontier-eval --algorithmic 1 solution.cpp --unbounded
```
### Customized Problems
1. Create `problems/{id}/` directory
2. Add required files:
- `statement.txt`: Problem description
- `config.yaml`: Limits and test count
- `testdata/`: Input/output files
- `chk.cc` or `interactor.cc`: Checker/interactor
3. Restart judge to pick up new problems
### Judge Sever Configuration
#### config.yaml
```yaml
time_limit: 1000 # ms
memory_limit: 262144 # KB
test_count: 10
checker: chk.cc # or interactor: interactor.cc
```
#### docker-compose.yml
```yaml
environment:
PORT: "8081" # API port
JUDGE_WORKERS: "8" # Concurrent evaluations
GJ_PARALLELISM: "8" # go-judge parallelism
```
|