42 lines
1.1 KiB
Python
Executable file
42 lines
1.1 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
flag_dict = {
|
|
0: ['OK', 'Ok'],
|
|
1: ['ERR', 'Err'],
|
|
2: ['AC', 'Accepted'],
|
|
3: ['RJ', 'Rejected'],
|
|
4: ['MLE', 'MemoryLimitExceeded'],
|
|
5: ['TLE', 'TimeLimitExceeded'],
|
|
6: ['WA', 'WrongAnswer'],
|
|
7: ['TD', 'TamperingDetected'],
|
|
8: ['PE', 'ProgramError'],
|
|
9: ['OE', 'OtherError'],
|
|
10: [None, 'Final'],
|
|
11: [None, 'ExecutionFinal'],
|
|
31: ['NIC', 'Nice'],
|
|
}
|
|
|
|
parser = argparse.ArgumentParser(
|
|
prog='GOJ Flag Decoder',
|
|
description='Decoder for GOJ status flags'
|
|
)
|
|
|
|
parser.add_argument('flags', help='the flags you would like to decode (as a 32 bit signed int)')
|
|
|
|
args = parser.parse_args()
|
|
|
|
flags = int(args.flags)
|
|
|
|
for flag in range(0, 32):
|
|
if (flags & 2 ** flag) == 2 ** flag:
|
|
desc_list = flag_dict.get(flag)
|
|
|
|
if desc_list is None:
|
|
print(f'{flag}: Unknown')
|
|
continue
|
|
|
|
if desc_list[0] is None:
|
|
print(f'{flag}: {desc_list[1]}')
|
|
else:
|
|
print(f'{flag}: {desc_list[0]} ({desc_list[1]})')
|