You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 lines
12 KiB

<% include util %>
<%
// Sanitize judge results for backward compatibility and clarity
if (!judge.result.subtasks) {
judge.result.subtasks = [
{ case_num: judge.result.case_num, status: judge.status, score: judge.result.score }
];
for (let i = 0; i < judge.result.case_num; ++i) {
judge.result.subtasks[0][i] = judge.result[i];
}
}
let runningFound = false;
for (let s of judge.result.subtasks) {
s.pending = (s.status === 'Waiting' || s.status.startsWith('Running'));
for (let i = 0; i < s.case_num; ++i) if (!s[i]) {
s[i] = {
pending: true,
status: runningFound ? 'Waiting' : 'Running'
};
if (!runningFound) s.isActiveSubtask = true;
runningFound = true;
}
}
%>
<%
let problemUrl;
if (typeof contest !== 'undefined') problemUrl = syzoj.utils.makeUrl(['contest', contest.id, judge.problem_id]);
else problemUrl = syzoj.utils.makeUrl(['problem', judge.problem_id]);
%>
<div class="padding">
<table class="ui very basic center aligned table" id="status_table" style="visibility: hidden; ">
<thead>
<tr>
<th>编号</th>
<th>题目名称</th>
<th>状态</th>
<% if ((typeof contest === 'undefined' || !contest) || !((!user || !user.is_admin) && !contest.ended && (contest.type === 'acm' || contest.type === 'noi'))) { %>
<th>分数</th>
<% } %>
<% if (judge.problem.type !== 'submit-answer') { %>
<th>总时间</th>
<th>内存</th>
<th>代码</th>
<% } else { %>
<th>文件大小</th>
<% } %>
<th>提交者</th>
<th>提交时间</th>
</tr>
</thead>
<tbody>
<tr>
<td>#<%= judge.id %></td>
<td><a style="width: 230px; height: 22px; display: block; margin: 0 auto; line-height: 22px; " id="text-fit" href="<%= problemUrl %>"><%= (typeof contest !== 'undefined' && contest) ? this.alpha(judge.problem_id) : ('#' + judge.problem_id) %>. <%= judge.problem.title %></a></td>
<td class="status <%= getStatusMeta(judge.status).toLowerCase().split(' ').join('_') %>">
<i class="<%= icon[getStatusMeta(judge.status)] || 'remove' %> icon"></i>
<%= judge.status %>
</td>
<% if ((typeof contest === 'undefined' || !contest) || !((!user || !user.is_admin) && !contest.ended && (contest.type === 'acm' || contest.type === 'noi'))) { %>
<td class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></td>
<% } %>
<% if (judge.problem.type !== 'submit-answer') { %>
<td><%= judge.result.total_time %> ms</td>
<td><%= parseInt(judge.result.max_memory) || 0 %> K</td>
<% if (judge.allowedSeeCode) { %>
<td><%= syzoj.config.languages[judge.language].show %> / <%= syzoj.utils.formatSize(judge.codeLength) %></td>
<% } else { %>
<td><%= syzoj.config.languages[judge.language].show %> / 隐藏 %></td>
<% } %>
<% } else { %>
<td><%= syzoj.utils.formatSize(judge.max_memory) %></td>
<% } %>
<td><a href="<%= syzoj.utils.makeUrl(['user', judge.user_id]) %>"><%= judge.user.username %></a><% if (judge.user.nameplate) { %><%- judge.user.nameplate %><% } %></td>
<td><%= syzoj.utils.formatDate(judge.submit_time) %></td>
</tr>
</tbody>
</table>
<script>
window.applyTextFit = function () {
var e = document.getElementById('text-fit');
textFit(e, { maxFontSize: 14 });
document.getElementById('status_table').style.visibility = '';
}
window.applyTextFit();
</script>
<% if (judge.problem.type !== 'submit-answer' && judge.allowedSeeCode) { %>
<div class="ui existing segment" style="position: relative; ">
<% if (judge.allowedRejudge) { %>
<a id="rejudge-button" href="<%= syzoj.utils.makeUrl(['submission', judge.id, 'rejudge']) %>" class="ui button" style="position: absolute; top: 0px; right: -4px; border-top-left-radius: 0; border-bottom-right-radius: 0; <% if (judge.pending) { %>display: none; <% } %>">重新评测</a>
<% } %>
<pre style="margin-top: 0; margin-bottom: 0; "><code id="code"><%- judge.code %></code></pre>
</div>
<script>
document.addEventListener('keydown', function (event) {
if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
var sel = window.getSelection();
var rg = document.createRange()
rg.selectNodeContents(document.getElementById('code'));
sel.removeAllRanges();
sel.addRange(rg);
event.preventDefault();
}
});
</script>
<% } %>
<% if (judge.problem.type !== 'submit-answer' && judge.result.compiler_output && judge.status === 'Compile Error' && judge.allowedSeeCode) { %>
<h3 class="ui header">编译信息</h3>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%- syzoj.utils.ansiToHTML(judge.result.compiler_output) %></code></pre></div>
<% } else if (judge.result.spj_compiler_output) { %>
<h3 class="ui header">Special Judge 编译信息</h3>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%- syzoj.utils.ansiToHTML(judge.result.spj_compiler_output) %></code></pre></div>
<% } else if (judge.allowedSeeCase && judge.result.subtasks && (judge.result.subtasks.length !== 1 || judge.result.subtasks[0].case_num)) { %>
<div class="ui styled fluid accordion" id="subtasks_list">
<% let subtask_count = 0; %>
<% for (let subtask_cases of (judge.result.subtasks || [])) { %>
<% if (judge.result.subtasks.length !== 1) { %>
<div class="title auto_update auto_update_activation<% if (subtask_cases.isActiveSubtask) { %> active<% } %>">
<div class="ui grid">
<div class="three wide column"><i class="dropdown icon"></i>子任务 #<%= ++subtask_count %></div>
<div class="four wide column status status_detail <%= getStatusMeta(subtask_cases.status).toLowerCase().split(' ').join('_') %>">
<i class="<%= icon[getStatusMeta(subtask_cases.status)] || 'remove' %> icon"></i>
<%= subtask_cases.status %></div>
<% if (!subtask_cases.pending) { %>
<div class="three wide column">得分:<span style="font-weight: normal; "><%= parseFloat(subtask_cases.score.toFixed(2)).toString() %></span></div>
<% } %>
</div>
</div>
<div class="content auto_update_activation<% if (subtask_cases.isActiveSubtask) { %> active<% } %>">
8 years ago
<div class="accordion" style="margin-top: 0; ">
<% } %>
<% for (let i = 0; i < subtask_cases.case_num; i++) { %>
<% let testcase = subtask_cases[i]; %>
<div class="title<% if (testcase.pending || !judge.allowedSeeData || testcase.status === 'Skipped') { %> pending<% } %> auto_update"<% if (testcase.pending || !judge.allowedSeeData) { %> style="cursor: auto; "<% } %>>
<div class="ui grid">
<div class="three wide column"><i class="dropdown icon"></i>测试点 #<%= i + 1 %></div>
<div class="four wide column status status_detail <%= getStatusMeta(testcase.status).toLowerCase().split(' ').join('_') %>">
<i class="<%= icon[getStatusMeta(testcase.status)] || 'remove' %> icon"></i>
<%= testcase.status %></div>
<% if (!testcase.pending && testcase.status !== 'Skipped') { %>
<% if (!testcase.score) testcase.score = testcase.status === 'Accepted' ? 100 : 0; %>
<div class="three wide column">得分:<span style="font-weight: normal; "><%= parseFloat(testcase.score.toFixed(2)).toString() %></span></div>
<div class="three wide column">用时:<span style="font-weight: normal; "><%= testcase.time_used %> ms</span></div>
<div class="three wide column">内存:<span style="font-weight: normal; "><%= testcase.memory_used %> KiB</span></div>
<% } %>
</div>
</div>
<div class="content auto_update">
<% if (!testcase.pending && judge.allowedSeeData && testcase.status !== 'Skipped') { %>
<p>
<strong>输入文件<% if (testcase.input_file_name) { %>(<span style="font-family: monospace; "><%= testcase.input_file_name %></span>)<% } %></strong>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.input %></code></pre></div>
<strong>输出文件<% if (testcase.output_file_name) { %>(<span style="font-family: monospace; "><%= testcase.output_file_name %></span>)<% } %></strong>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.answer %></code></pre></div>
<strong>选手输出</strong>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.user_out %></code></pre></div>
<% if (testcase.spj_message) { %>
<strong>Special Judge 信息</strong>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.spj_message %></code></pre></div>
<% } %>
8 years ago
<% if (testcase.user_err) { %>
<strong>标准错误</strong>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.user_err %></code></pre></div>
<% } %>
<% if (testcase.runner_message && judge.allowedManage) { %>
<strong>调试信息</strong>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.runner_message %></code></pre></div>
<% } %>
</p>
<% } %>
</div>
<% } %>
<% if (judge.result.subtasks.length !== 1) { %>
</div></div>
<% } %>
<% } %>
</div>
<% } %>
</div>
<script>
$(function() {
$('.ui.accordion').accordion({
selector: {
trigger: '.title:not(.pending)'
}
});
});
</script>
<% if (!isPending(judge.status)) { %><div><div id="stop_ajax"></div><div id="show_rejudge"></div></div><% } %>
<script>
<% if (isPending(judge.status)) { %>
document.addEventListener('mousedown', function (event) {
var list = $('#submission_content').find('div.auto_update_activation');
for (var i = 0; i < list.length; ++i) {
$(list[i]).removeClass('auto_update_activation');
}
});
function update_submission() {
setTimeout(function () {
$.get('/submission/<%= judge.id %>/ajax', function (data) {
var e = $('#submission_content'), x = $($.parseHTML(data));
if (x.find('#show_rejudge').length) {
try {
document.getElementById('rejudge-button').style.display = '';
} catch (e) {}
}
if (e.find('td.status').text().trim() != x.find('td.status').text().trim()) {
var a = e.find('div.auto_update');
if (!a.length) {
e.html(data);
window.applyTextFit();
} else {
e.find('#status_table').html(x.find('#status_table').html());
var b = x.find('div.auto_update');
for (var i = 0; i < a.length; i++) {
a[i].innerHTML = b[i].innerHTML;
if (!$(b[i]).hasClass('pending')) $(a[i]).removeClass('pending');
if (!$(b[i]).attr('style')) $(a[i]).attr('style', '');
}
a = e.find('div.auto_update_activation');
b = x.find('div.auto_update_activation');
for (var i = 0; i < a.length; i++) {
if ($(b[i]).hasClass('active')) $(a[i]).addClass('active'); else $(a[i]).removeClass('active');
}
window.applyTextFit();
if (!x.find('#stop_ajax').length) update_submission();
}
}
else if (!x.find('#stop_ajax').length) update_submission();
});
}, 500);
}
update_submission();
<% } %>
</script>