Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CDS/src/org/icpc/tools/cds/CDSConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ private CDSConfig(File file) {
lastModified = file.lastModified();
try {
Element e = readElement(file);

if (e.hasAttribute("contest-api")) {
String spec = getString(e, "contest-api");
System.setProperty("ICPC_CONTEST_API", spec);
}

loadContests(e);
loadOtherConfig(e);

Expand Down
10 changes: 8 additions & 2 deletions CDS/src/org/icpc/tools/cds/service/ContestRESTService.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

@WebServlet(urlPatterns = { "/api", "/api/", "/api/*" }, asyncSupported = true)
public class ContestRESTService extends HttpServlet {
private static final boolean isDraftSpec = "draft".equals(System.getProperty("ICPC_CONTEST_API"));
private static final long serialVersionUID = 1L;

static class EndpointInfo {
Expand Down Expand Up @@ -274,8 +275,13 @@ private static void sendAPIInfo(HttpServletResponse response) throws IOException
je.encode("name", "Contest Data Server");
je.encodePrimitive("logo", "[{\"href\":\"/cdsIcon.png\",\"filename\":\"logo.png\","
+ "\"mime\":\"image/png\",\"width\":512,\"height\":512}]");
je.encode("version", "2025-draft");
je.encode("version_url", "https://ccs-specs.icpc.io/draft/contest_api");
if (isDraftSpec) {
je.encode("version", "2025-draft");
je.encode("version_url", "https://ccs-specs.icpc.io/draft/contest_api");
} else {
je.encode("version", "2023-06");
je.encode("version_url", "https://ccs-specs.icpc.io/2023-06/contest_api");
}
je.close();
}

Expand Down
20 changes: 10 additions & 10 deletions ContestModel/src/org/icpc/tools/contest/model/Scoreboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.icpc.tools.contest.model.internal.State;

public class Scoreboard {
private static final boolean is202306 = "2023-06".equals(System.getProperty("ICPC_CONTEST_API"));
private static final boolean isDraftSpec = "draft".equals(System.getProperty("ICPC_CONTEST_API"));

private static double round(double d) {
return Math.round(d * 100_000.0) / 100_000.0;
Expand Down Expand Up @@ -64,18 +64,18 @@ public static void writeScoreboard(PrintWriter pw, IContest contest) {
pw.write("\"score\":{");
if (ScoreboardType.PASS_FAIL.equals(scoreboardType)) {
pw.write("\"num_solved\":" + s.getNumSolved() + ",");
if (is202306) {
pw.write("\"total_time\":" + ContestUtil.getTime(s.getTime()) + "},\n");
} else {
if (!isDraftSpec) {
pw.write("\"total_time\":\"" + RelativeTime.format(s.getTime()) + "\"},\n");
} else {
pw.write("\"total_time\":" + ContestUtil.getTime(s.getTime()) + "},\n");
}
} else if (ScoreboardType.SCORE.equals(scoreboardType)) {
pw.write("\"score\":" + round(s.getScore()));
if (s.getLastSolutionTime() >= 0) {
if (is202306) {
pw.write(",\"time\":" + ContestUtil.getTime(s.getLastSolutionTime()) + "},\n");
} else {
if (isDraftSpec) {
pw.write(",\"time\":\"" + RelativeTime.format(s.getLastSolutionTime()) + "\"},\n");
} else {
pw.write(",\"time\":" + ContestUtil.getTime(s.getLastSolutionTime()) + "},\n");
}
} else
pw.write("},\n");
Expand All @@ -101,10 +101,10 @@ public static void writeScoreboard(PrintWriter pw, IContest contest) {
pw.write(",\"first_to_solve\":true");
} else if (ScoreboardType.SCORE.equals(scoreboardType))
pw.write("\"score\":" + round(r.getScore()));
if (is202306) {
pw.write(",\"time\":" + ContestUtil.getTime(r.getContestTime()));
} else {
if (isDraftSpec) {
pw.write(",\"time\":\"" + RelativeTime.format(r.getContestTime()) + "\"");
} else {
pw.write(",\"time\":" + ContestUtil.getTime(r.getContestTime()));
}
} else
pw.write("\"solved\":false");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.icpc.tools.contest.model.feed.Timestamp;

public class Info extends ContestObject implements IInfo {
private static final boolean is202306 = "2023-06".equals(System.getProperty("ICPC_CONTEST_API"));
private static final boolean isDraftSpec = "draft".equals(System.getProperty("ICPC_CONTEST_API"));

private static final String NAME = "name";
private static final String FORMAL_NAME = "formal_name";
Expand Down Expand Up @@ -341,10 +341,10 @@ else if (ScoreboardType.SCORE.equals(scoreboardType))
props.addLiteralString(SCOREBOARD_THAW_TIME, Timestamp.format(thawTime.longValue()));

if (penalty != null) {
if (is202306)
props.addInt(PENALTY_TIME, (int) (penalty.longValue() / (60 * 1000L)));
else
if (isDraftSpec)
props.addLiteralString(PENALTY_TIME, RelativeTime.format(penalty));
else
props.addInt(PENALTY_TIME, (int) (penalty.longValue() / (60 * 1000L)));
}

if (!Double.isNaN(timeMultiplier))
Expand Down