# Judge Girl Problem Labeling Guide
---
## Problem Labeling
In order to migrate all the problems automatically and make a guideline of how do admins create new problems, we have to survey through all the problems and attach proper labels on the problems. TA can then add new problems based on the labeling research. And the migration automation can be implemented based on the labels.
---
## How do you do the problem survey?
1. ssh into morris. (via special-student@morris.csie.ntu.edu.tw)
2. `cd ~/package`
> `~/package` is the mirror of the legacy Judge-Girl, where all the testdada and problems are backed up here.
3. Let's say, you are surveying the problem `3. Print Two Numbers`, where `3` is the problem's id, and `Print Two Numbers` is the problem's title.
3.1. do `cd testdata/3`
3.2. And you will see the following directory structure (under `~/package/testdata/3`), where the `.in` and `.out` files are the standard inputs and outputs to the tested program. :
```
├── 0.in
├── 0.out
├── 1.in
├── 1.out
├── 2.in
├── 2.out
├── 3.in
├── 3.out
├── 4.in
├── 4.out
├── 5.in
├── 5.out
├── judge
├── special
└── subtasks.py
```
---
3.3 You need to read and understand the `judge` and `subtasks.py` files carefully, to understand the judge flow's code.
> Under the `build()` funcion in the `judge` file, find the compilation script starts with `gcc`.
3.4 Add a problem record into [this google sheet](https://docs.google.com/spreadsheets/d/1ItBYeTH5UUM7HrIdtyrqfjiNXM7qzZbITIwmuu-qh70/edit?usp=sharing), if you find that the problem's `judge` and `subtasks.py` are **abnormal, consult 水球/魏宏軒**, **consider adding a new problem label, and take note into the Note field**.
Examples
---
subtasks.py
---
```python=
[
[ 0, ['0.in', '0.out', 1, 64 << 20, 64 << 10]]
,[ 20, ['1.in', '1.out', 1, 64 << 20, 64 << 10]]
,[ 20, ['2.in', '2.out', 1, 64 << 20, 64 << 10]]
,[ 20, ['3.in', '3.out', 1, 64 << 20, 64 << 10]]
,[ 20, ['4.in', '4.out', 1, 64 << 20, 64 << 10]]
,[ 20, ['5.in', '5.out', 1, 64 << 20, 64 << 10]]
]
```
The `subtasks.py` file declares the `testcases`.
For example: `[ 20, ['1.in', '1.out', 1, 64 << 20, 64 << 10]`
--> Grade: 30, stdin: `1.in`, stdout: `1.out`, Time Limit: 1, Memory Limit: `64 << 20`, Output Limit: `64 <<10`
---
judge
---
```python=
def run(tl, ml, ol, ifn):
if lid == 1 or lid == 2:
c = '../app/a.out'
elif lid == 3:
c = 'mono ../app/a.exe'
elif lid == 4:
c = 'python3 -B ../app/a.py'
elif lid == 5:
c = 'scala -cp ../app Main'
else:
assert False
return os.system('sandbox %d %d %s <\'%s\' 2>/dev/null | tiger %d' % (tl, ml, c, ifn, ol))
def build():
T = '(%s 2>&1; echo $? >es) | tiger 4096; exit `cat es`'
while True:
if lid == 1:
os.rename('source', 'a.c')
if os.system(T % 'timeout 10 gcc -std=c99 -O2 a.c -lm') != 0: break
assert os.system('mv a.out /sandbox/sandbox/app') == 0
elif lid == 2:
os.rename('source', 'a.cpp')
if os.system(T % 'timeout 10 g++ -std=c++98 -O2 a.cpp -lm') != 0: break
assert os.system('mv a.out /sandbox/sandbox/app') == 0
elif lid == 3:
os.rename('source', 'a.cs')
if os.system(T % 'mcs -langversion:3 a.cs') != 0: break
assert os.system('mv a.exe /sandbox/sandbox/app') == 0
elif lid == 4:
assert os.system('mv source /sandbox/sandbox/app/a.py') == 0
elif lid == 5:
os.rename('source', 'a.scala')
if os.system(T % 'scalac -optimise a.scala') != 0: break
assert os.system('mv *.class /sandbox/sandbox/app') == 0
else:
exit(0, const.CE, 0, 0, b'unsupported language\n')
return
exit(0, const.CE, 0, 0, read('/run/shm/slave.out'))
def main():
assert len(sys.argv) == 2
global lid
lid = int(sys.argv[1])
build()
get('subtasks.py')
get('special')
scr, vd, cpu, mem, dtl = 0, const.AC, 0, 0, ''
for subtask in eval(read('subtasks.py')):
dtl += 'Subtask (%dpt)\n\n' % subtask[0]
flg = True
for trial in subtask[1:]:
ifn, ofn, tl, ml, ol = trial
get(ifn)
res = run(tl, ml, ol, ifn)
log = read('/run/shm/slave.log').decode().split()
cpu = max(cpu, int(log[1]))
mem = max(mem, int(log[2]))
if res != 0:
tvd = const.OLE
elif log[0] == 'MLE':
tvd = const.MLE
elif log[0] == 'RE':
tvd = const.RE
elif log[0] == 'TLE':
tvd = const.TLE
else:
assert log[0] == 'OK'
get(ofn)
if os.system('./special \'%s\' \'%s\' /run/shm/slave.out >/dev/null 2>&1' % (ifn, ofn)) != 0:
tvd = const.WA
else:
tvd = const.AC
dtl += '%s\ncpu %d ms\nmem %d B\n%s\n\n' % (ifn, int(log[1]), int(log[2]), const.res[tvd])
vd = min(vd, tvd)
if tvd != const.AC:
flg = False
if flg: scr += subtask[0]
exit(scr, vd, cpu, mem, dtl.encode())
if __name__ == '__main__': main()
```
> **Look at the line 19th, it's the compilation script for `C`.**
{"metaMigratedAt":"2023-06-15T18:29:30.641Z","metaMigratedFrom":"Content","title":"Judge Girl Problem Labeling Guide","breaks":true,"contributors":"[{\"id\":\"76b470af-d941-496c-9f55-5841ff4dfd27\",\"add\":10365,\"del\":5516},{\"id\":\"4f482ee9-95e2-4e79-8f87-56ebe9744fd7\",\"add\":95,\"del\":107},{\"id\":\"5056ee68-447f-4cb3-bf97-90043951e767\",\"add\":1,\"del\":60}]"}