Пример #1
0
def main(argv=None):
    if argv is None:
        argv = sys.argv[1:]
    args = docopt(__doc__, argv=argv)
    ct = Contest.from_dict({
        'metadata': {'title': 'Resource test'},
        'contestants': [{
            'name': 'Test',
            'path': '.',
        }],
        'problems': [{
            'type': 'resource-test',
            'name': 'Resource test',
            'input-file': args['<program>'] + '.in',
            'source-path': args['<program>'],
            'testcases': [
                {
                    'input-file': input_file,
                    'resource-limits': {
                        'time-limit': float(args['<time_limit>']),
                        'memory-limit':
                            int(float(args['<memory_limit>']) *
                                1024 * 1024),
                    },
                }
                for input_file in args['<input_file>']
            ],
        }],
    })
    ct.judge_all(TerminalFormatter())
Пример #2
0
def main(argv=None):
    if argv is None:
        argv = sys.argv[1:]
    args = docopt(__doc__, argv=argv)
    try:
        ct = Contest.from_yaml_file(args['--contest'])
    except FileNotFoundError:
        print('Contest configuration not found.', file=sys.stderr)
        return 1
    if args['--source-path'] is None:
        contest_results = ct.judge_all(TerminalFormatter())
        with open(args['--output-results'], 'w') as fout:
            fout.write(yaml.safe_dump(contest_results))
    else:
        ct.judge_contestant_path(args['--source-path'],
                                 TerminalFormatter())