-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.py
More file actions
70 lines (60 loc) · 1.5 KB
/
Copy pathexample.py
File metadata and controls
70 lines (60 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import asyncio
import logging
from uuid import uuid4
from rich import print
from rich.logging import RichHandler
from rich.traceback import install as install_traceback
from judger import *
def setup_logger():
logger = logging.getLogger(LOGGER_NAME)
logger.setLevel(logging.DEBUG)
console_handler = RichHandler(
log_time_format="[%X.%f]",
rich_tracebacks=True)
logger.addHandler(console_handler)
async def main():
install_traceback()
setup_logger()
endpoint = 'http://localhost:5050'
testcases = [
Testcase(
uuid=str(uuid4()),
input=MemoryFile("1 1\n"),
output=MemoryFile("2\n")
),
Testcase(
uuid=str(uuid4()),
input=MemoryFile("1 -1\n"),
output=MemoryFile("0\n")
),
Testcase(
uuid=str(uuid4()),
input=MemoryFile("0 0\n"),
output=MemoryFile("0\n")
)
]
code = r"""
#include <stdio.h>
int main()
{
int a,b;
while(scanf("%d %d",&a, &b) != EOF)
printf("%d\n",(a+b)*2);
return 0;
}
"""
submission = Submission(
sid=1,
timeLimit=1000,
memoryLimit=32768,
testcases=testcases,
language=Language.C,
code=code
)
print(submission)
async with SandboxClient(endpoint) as client:
judger = Judger(client, submission)
result = await judger.get_result()
print(result)
if __name__ == '__main__':
asyncio.run(main())