Mercurial > ~astiob > upreckon > hgweb
view 2.00/problem.py @ 17:dfe872cafbd0
$Rev: $ in test-svn.py 2.00 should now work
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Mon, 07 Jun 2010 23:38:13 +0000 |
parents | f2279b7602d3 |
children | ec6f1a132109 |
line wrap: on
line source
#!/usr/bin/python # Copyright (c) 2010 Chortos-2 <chortos@inbox.lv> try: import config as _config, testcases as _testcases except ImportError as e: import __main__ __main__.import_error(e) # LIBRARY and STDIO refer to interactive aka reactive problems BATCH, OUTONLY, LIBRARY, STDIO, BESTOUT = xrange(5) class Problem(object): __slots__ = 'name', 'config', 'cache', 'testcases' def __init__(prob, name): if not isinstance(name, basestring): # This shouldn't happen, of course raise TypeError, "Problem() argument 1 must be string, not " + str(type(name)).split('\'')[1] prob.name = name prob.config = _config.load_problem(name) prob.cache = type('Cache', (object,), {'padoutputtolength': 0})() prob.testcases = _testcases.load_problem(prob) def test(prob): real = max = 0 for case in prob.testcases: r, m = case() real += r max += m return real, max