Datasets:
add evaluation example
Browse files
README.md
CHANGED
|
@@ -56,8 +56,72 @@ To validate the reliability of this benchmark, we run both correct and represent
|
|
| 56 |
|
| 57 |
```python
|
| 58 |
from datasets import load_dataset
|
|
|
|
|
|
|
| 59 |
|
| 60 |
dataset = load_dataset("stepfun-ai/CF-Div2-Stepfun", name="release_v1", split="test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
```
|
| 62 |
|
| 63 |
## Evaluation Details
|
|
@@ -85,7 +149,7 @@ You are a coding expert. Given a competition-level coding problem, you need to w
|
|
| 85 |
The compilation and execution commands for C++, Python, Java are given below:
|
| 86 |
|
| 87 |
```
|
| 88 |
-
g++ -std=c++20 -fno-asm -fsanitize=bounds -fno-sanitize-recover=bounds
|
| 89 |
./code.exe
|
| 90 |
```
|
| 91 |
|
|
|
|
| 56 |
|
| 57 |
```python
|
| 58 |
from datasets import load_dataset
|
| 59 |
+
from pathlib import Path
|
| 60 |
+
import os
|
| 61 |
|
| 62 |
dataset = load_dataset("stepfun-ai/CF-Div2-Stepfun", name="release_v1", split="test")
|
| 63 |
+
|
| 64 |
+
# An evaluation example is given below for problem id=1:
|
| 65 |
+
# make sure you have prepared necessary checkers first
|
| 66 |
+
# here the checker used is "ncmp" as an example, for other problems inspect the marked checker name
|
| 67 |
+
# > git clone https://github.com/MikeMirzayanov/testlib.git
|
| 68 |
+
# > g++ -std=c++20 -Wall -Wextra --static -I testlib/ testlib/checkers/ncmp.cpp -o ncmp
|
| 69 |
+
assert dataset[0]["problem_id"] == "codeforces/2020A"
|
| 70 |
+
assert dataset[0]["checker"] == "ncmp"
|
| 71 |
+
|
| 72 |
+
# prepare a submission code
|
| 73 |
+
submission_code = \
|
| 74 |
+
r"""
|
| 75 |
+
#include <bits/stdc++.h>
|
| 76 |
+
using namespace std;
|
| 77 |
+
|
| 78 |
+
int find_min_oper(int n, int k){
|
| 79 |
+
if(k == 1) return n;
|
| 80 |
+
int ans = 0;
|
| 81 |
+
while(n){
|
| 82 |
+
ans += n%k;
|
| 83 |
+
n /= k;
|
| 84 |
+
}
|
| 85 |
+
return ans;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
int main()
|
| 89 |
+
{
|
| 90 |
+
int t;
|
| 91 |
+
cin >> t;
|
| 92 |
+
while(t--){
|
| 93 |
+
int n,k;
|
| 94 |
+
cin >> n >> k;
|
| 95 |
+
cout << find_min_oper(n,k) << "\n";
|
| 96 |
+
}
|
| 97 |
+
return 0;
|
| 98 |
+
}
|
| 99 |
+
"""
|
| 100 |
+
|
| 101 |
+
eval_dir = Path("./eval_test")
|
| 102 |
+
eval_dir.mkdir(exist_ok=True)
|
| 103 |
+
with open(eval_dir / "code.cpp", "w") as fout:
|
| 104 |
+
fout.write(submission_code)
|
| 105 |
+
|
| 106 |
+
# run compilation
|
| 107 |
+
ret = os.system(f"g++ -std=c++20 -fno-asm -fsanitize=bounds -fno-sanitize-recover=bounds -static -O2 -DONLINE_JUDGE -o {eval_dir / 'code.exe'} {eval_dir / 'code.cpp'}")
|
| 108 |
+
assert ret == 0
|
| 109 |
+
|
| 110 |
+
for idx, test_case in enumerate(dataset[0]["test_cases"]):
|
| 111 |
+
|
| 112 |
+
with open(eval_dir / f"{idx}.in", "w") as fout:
|
| 113 |
+
fout.write(test_case["input"])
|
| 114 |
+
with open(eval_dir / f"{idx}.ans", "w") as fout:
|
| 115 |
+
fout.write(test_case["output"])
|
| 116 |
+
|
| 117 |
+
# run code
|
| 118 |
+
# apply more time / space constraints if you like
|
| 119 |
+
ret = os.system(f"{eval_dir / 'code.exe'} < {eval_dir}/{idx}.in > {eval_dir}/{idx}.out")
|
| 120 |
+
assert ret == 0
|
| 121 |
+
|
| 122 |
+
# run checker
|
| 123 |
+
ret = os.system(f"./ncmp {eval_dir}/{idx}.in {eval_dir}/{idx}.out {eval_dir}/{idx}.ans")
|
| 124 |
+
assert ret == 0
|
| 125 |
```
|
| 126 |
|
| 127 |
## Evaluation Details
|
|
|
|
| 149 |
The compilation and execution commands for C++, Python, Java are given below:
|
| 150 |
|
| 151 |
```
|
| 152 |
+
g++ -std=c++20 -fno-asm -fsanitize=bounds -fno-sanitize-recover=bounds -static -O2 -DONLINE_JUDGE -o code.exe code.cpp
|
| 153 |
./code.exe
|
| 154 |
```
|
| 155 |
|