Skip to content

Commit

Permalink
Merge pull request #26 from online-judge-tools/fix/topcoder
Browse files Browse the repository at this point in the history
Update about Topcoder
  • Loading branch information
kmyk authored Jun 15, 2020
2 parents bcfbd4b + 7918b28 commit 7b6db90
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
from onlinejudge_template.generator._utils import get_analyzed


def is_topcoder(data: Dict[str, Any]) -> bool:
definition = get_analyzed(data).topcoder_class_definition
return definition is not None


def class_name(data: Dict[str, Any]) -> str:
definition = get_analyzed(data).topcoder_class_definition
if definition is None:
Expand Down
14 changes: 13 additions & 1 deletion onlinejudge_template_resources/template/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import platform

import onlinejudge_template.generator.cplusplus as cplusplus
import onlinejudge_template.generator.topcoder as topcoder
import onlinejudge_template.generator.about as about
%>\
<%
Expand All @@ -27,17 +28,28 @@
using namespace std;

${cplusplus.declare_constants(data)}
% if topcoder.is_topcoder(data):
<% solve_function = topcoder.class_name(data) + "()." + topcoder.method_name(data) %>\
class ${topcoder.class_name(data)} {
public:
${cplusplus.return_type(data)} ${topcoder.method_name(data)}(${cplusplus.formal_arguments(data)}) {
// TODO: edit here
}
};
% else:
<% solve_function = "solve" %>\
${cplusplus.return_type(data)} solve(${cplusplus.formal_arguments(data)}) {
// TODO: edit here
}
% endif

// generated by ${about.title} ${about.version} (${about.url})
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
constexpr char endl = '\n';
${cplusplus.read_input(data)}
auto ${cplusplus.return_value(data)} = solve(${cplusplus.actual_arguments(data)});
auto ${cplusplus.return_value(data)} = ${solve_function}(${cplusplus.actual_arguments(data)});
${cplusplus.write_output(data)}
return 0;
}
45 changes: 0 additions & 45 deletions onlinejudge_template_resources/template/topcoder.cpp

This file was deleted.

0 comments on commit 7b6db90

Please sign in to comment.