Skip to content

Commit

Permalink
tiericpc
Browse files Browse the repository at this point in the history
  • Loading branch information
hieplpvip committed Jul 31, 2024
1 parent 541f5c3 commit 83bf9bd
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .docker/tiericpc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM vnoj/runtimes-tiericpc

ARG TAG=tiericpc

RUN mkdir /judge /problems && cd /judge && \
curl -L https://github.com/VNOI-Admin/judge-server/archive/"${TAG}".tar.gz | tar -xz --strip-components=1 && \
python3 -m venv --prompt=DMOJ /env && \
/env/bin/pip3 install cython && \
/env/bin/pip3 install -e . && \
/env/bin/python3 setup.py develop && \
HOME=~judge . ~judge/.profile && \
runuser -u judge -w PATH -- /env/bin/dmoj-autoconf -V > /judge-runtime-paths.yml && \
echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml && \
/judge/.docker/download_testlib_and_precompile

ENTRYPOINT ["/usr/bin/tini", "--", "/judge/.docker/entry"]
45 changes: 45 additions & 0 deletions dmoj/executors/CICPC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from typing import List

from dmoj.executors.base_executor import VersionFlags
from dmoj.executors.c_like_executor import CExecutor, GCCMixin


class Executor(GCCMixin, CExecutor):
command = 'gcc'
std = 'gnu11'
command_paths = ['gcc']

test_program = """
#include <stdio.h>
#if __STDC_VERSION__ == 201112
int main() {
int ch;
while ((ch = getchar()) != EOF)
putchar(ch);
return 0;
}
#endif
"""

def get_defines(self) -> List[str]:
return self.defines

def get_flags(self) -> List[str]:
return ['-x', 'c', '-g', '-O2', '-std=gnu11', '-static', '-lm']

def get_compile_args(self) -> List[str]:
command = self.get_command()
assert command is not None
return (
[command]
+ (['-fdiagnostics-color=always'] if self.has_color else [])
+ self.source_paths
+ self.get_defines()
+ self.get_flags()
+ ['-o', self.get_compiled_file()]
)

@classmethod
def get_version_flags(cls, command: str) -> List[VersionFlags]:
return ['--version']
44 changes: 44 additions & 0 deletions dmoj/executors/CPPICPC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from typing import List

from dmoj.executors.base_executor import VersionFlags
from dmoj.executors.c_like_executor import CPPExecutor, GCCMixin


class Executor(GCCMixin, CPPExecutor):
command = 'g++'
command_paths = ['g++-11', 'g++']
std = 'gnu++20'
test_program = """
#include <iostream>
#if __cplusplus == 202002
int main() {
std::strong_ordering comparison = 1 <=> 2;
auto input = std::cin.rdbuf();
std::cout << input;
return 0;
}
#endif
"""

def get_defines(self) -> List[str]:
return self.defines

def get_flags(self) -> List[str]:
return ['-x', 'c++', '-g', '-O2', '-std=gnu++20', '-static']

def get_compile_args(self) -> List[str]:
command = self.get_command()
assert command is not None
return (
[command]
+ (['-fdiagnostics-color=always'] if self.has_color else [])
+ self.source_paths
+ self.get_defines()
+ self.get_flags()
+ ['-o', self.get_compiled_file()]
)

@classmethod
def get_version_flags(cls, command: str) -> List[VersionFlags]:
return ['--version']

0 comments on commit 83bf9bd

Please sign in to comment.