Skip to content

Commit 16adf41

Browse files
author
iotang
committed
子任务依赖现在会以比例限制得分
1 parent f802e78 commit 16adf41

13 files changed

+312
-222
lines changed

assignmentthread.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
**/
2626

2727
#include "globaltype.h"
28+
#include "subtaskdependencelib.h"
2829
#include "assignmentthread.h"
2930

3031
#include <utility>
@@ -382,7 +383,7 @@ void AssignmentThread::run()
382383
memoryUsed.append(QList<int>());
383384
score.append(QList<int>());
384385
result.append(QList<ResultState>());
385-
overallStatus.append(2);
386+
overallStatus.append(mxDependValue);
386387
message.append(QStringList());
387388
inputFiles.append(QStringList());
388389
testCaseScore.append(task->getTestCase(i)->getFullScore());
@@ -413,7 +414,7 @@ void AssignmentThread::assign()
413414
}
414415

415416
TestCase *curTestCase = task->getTestCase(curTestCaseIndex);
416-
bool beingSkipped = false;
417+
bool isSkipped = 0;
417418

418419
if (curSingleCaseIndex == curTestCase->getInputFiles().size())
419420
{
@@ -438,26 +439,32 @@ void AssignmentThread::assign()
438439
curTestCase = task->getTestCase(curTestCaseIndex);
439440
const QList<int> &dependenceSubtask(curTestCase->getDependenceSubtask());
440441

442+
overallStatus[curTestCaseIndex] = mxDependValue;
443+
441444
for (int i = 0; i != dependenceSubtask.size(); ++i)
442445
{
443446
int status = overallStatus[dependenceSubtask[i] - 1];
444-
emit singleSubtaskDependenceFinished(curTestCaseIndex, i, status);
447+
emit singleSubtaskDependenceFinished(curTestCaseIndex, dependenceSubtask[i], status);
448+
449+
if (status < 0) isSkipped = 1;
445450

446-
if (status <= 0)beingSkipped = true;
451+
overallStatus[curTestCaseIndex] = qMin(overallStatus[curTestCaseIndex], status);
447452
}
448453

449454
if (! dependenceSubtask.empty())
450-
score[curTestCaseIndex].push_back(-1 - beingSkipped);
455+
score[curTestCaseIndex].push_back(overallStatus[curTestCaseIndex]);
451456
}
452457

453458
totalSingleCase ++;
454459
curTestCase = task->getTestCase(curTestCaseIndex);
455460
inputFiles[curTestCaseIndex][curSingleCaseIndex]
456461
= QFileInfo(curTestCase->getInputFiles().at(curSingleCaseIndex)).fileName();
457462

458-
if (overallStatus[curTestCaseIndex] <= 0 || beingSkipped)
463+
testCaseScore[curTestCaseIndex] = qMin(testCaseScore[curTestCaseIndex], statusToScore(overallStatus[curTestCaseIndex], curTestCase->getFullScore()));
464+
465+
if (overallStatus[curTestCaseIndex] < 0 || isSkipped)
459466
{
460-
overallStatus[curTestCaseIndex] = 0;
467+
overallStatus[curTestCaseIndex] = -1;
461468
taskSkipped(qMakePair(curTestCaseIndex, curSingleCaseIndex++));
462469
return;
463470
}
@@ -573,7 +580,7 @@ void AssignmentThread::threadFinished()
573580
memoryUsed[cur.first][cur.second] = thread->getMemoryUsed();
574581
score[cur.first][cur.second] = thread->getScore();
575582
result[cur.first][cur.second] = thread->getResult();
576-
overallStatus[cur.first] = qMin(overallStatus[cur.first], stateToStatus(thread->getResult()));
583+
overallStatus[cur.first] = qMin(overallStatus[cur.first], stateToStatus(thread->getResult(), thread->getScore(), thread->getFullScore()));
577584
message[cur.first][cur.second] = thread->getMessage();
578585
running.remove(thread);
579586
countFinished ++;
@@ -584,6 +591,9 @@ void AssignmentThread::threadFinished()
584591
{
585592
for (int i = 0; i < cur.second; i++)
586593
nowScore = qMin(nowScore, score[cur.first][i]);
594+
595+
if (!task->getTestCase(cur.first)->getDependenceSubtask().empty())
596+
nowScore = qMin(nowScore, statusToScore(overallStatus[curTestCaseIndex], task->getTestCase(cur.first)->getFullScore()));
587597
}
588598

589599
emit singleCaseFinished(task->getTestCase(cur.first)->getTimeLimit(),

detaildialog.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "contest.h"
3232
#include "contestant.h"
3333
#include "globaltype.h"
34+
#include "subtaskdependencelib.h"
3435
#include "settings.h"
3536
#include "judgingdialog.h"
3637
#include <QMessageBox>
@@ -150,7 +151,7 @@ void DetailDialog::refreshViewer(Contest *_contest, Contestant *_contestant)
150151
.arg(inputFiles[j].size()).arg(j + 1);
151152
else
152153
htmlCode += QString(R"(<td nowrap="nowrap" rowspan="%1" align="center" valign="middle">#%2<br>%3:%4</td>)")
153-
.arg(inputFiles[j].size()).arg(j + 1).arg(tr("Subtask Dependence Status")).arg(score[j].back() == -1 ? tr("Success") : tr("Failed"));
154+
.arg(inputFiles[j].size()).arg(j + 1).arg(tr("Subtask Dependence Status")).arg(statusRankingText(score[j].back()));
154155
}
155156

156157
htmlCode += QString(R"(<td nowrap="nowrap" align="center" valign="middle">%1</td>)").arg(inputFiles[j][k]);
@@ -199,10 +200,25 @@ void DetailDialog::refreshViewer(Contest *_contest, Contestant *_contestant)
199200
for (int t = 0; t < inputFiles[j].size(); t ++)
200201
if (score[j][t] < minv) minv = score[j][t];
201202

202-
QString bgColor = "rgb(255, 192, 192)";
203+
int tempStatus = mxDependValue + 1;
203204

204-
if (minv >= maxv) bgColor = "rgb(192, 255, 192)";
205-
else if (minv > 0) bgColor = "rgb(192, 255, 255)";
205+
if (!testCases[j]->getDependenceSubtask().empty())
206+
{
207+
tempStatus = score[j].back();
208+
minv = qMin(minv, statusToScore(score[j].back(), maxv));
209+
}
210+
211+
QString bgColor = "rgb(192, 255, 192)";
212+
213+
for (int t = 0; t < inputFiles[j].size(); t ++)
214+
if (result[j][t] != CorrectAnswer)bgColor = "rgb(192, 255, 255)";
215+
216+
if (tempStatus < mxDependValue)bgColor = "rgb(192, 255, 255)";
217+
218+
for (int t = 0; t < inputFiles[j].size(); t ++)
219+
if (result[j][t] != CorrectAnswer && result[j][t] != PartlyCorrect)bgColor = "rgb(255, 192, 192)";
220+
221+
if (tempStatus < 0)bgColor = "rgb(255, 192, 192)";
206222

207223
htmlCode += QString(R"(<td rowspan="%1" align="center" valign="middle" style="background-color: %2;"><a style="font-weight: bold; font-size: large;">%3</a> / %4</td>)").arg(inputFiles[j].size()).arg(bgColor).arg(minv).arg(maxv);
208224
}

exportutil.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "testcase.h"
3131
#include "contestant.h"
3232
#include "globaltype.h"
33+
#include "subtaskdependencelib.h"
3334
#include "settings.h"
3435
#include "visualsettings.h"
3536
#include <algorithm>
@@ -140,7 +141,7 @@ auto ExportUtil::getContestantHtmlCode(Contest *contest, Contestant *contestant,
140141
.arg(inputFiles[j].size()).arg(j + 1);
141142
else
142143
htmlCode += QString(R"(<td rowspan="%1" style="border-style: none solid solid none; border-width: 1px 3px; border-color: #ccc;">#%2<br>%3:%4</td>)")
143-
.arg(inputFiles[j].size()).arg(j + 1).arg(tr("Subtask Dependence Status")).arg(score[j].back() == -1 ? tr("Success") : tr("Failed"));
144+
.arg(inputFiles[j].size()).arg(j + 1).arg(tr("Subtask Dependence Status")).arg(statusRankingText(score[j].back()));
144145
}
145146

146147
htmlCode += QString("<td style=\"border-style: none solid solid none; border-width: 1px 3px; border-color: #ccc;\">%1</td>").arg(inputFiles[j][k]);
@@ -470,7 +471,7 @@ auto ExportUtil::getSmallerContestantHtmlCode(Contest *contest, Contestant *cont
470471
.arg(inputFiles[j].size()).arg(j + 1);
471472
else
472473
htmlCode += QString("<td rowspan=\"%1\">#%2<br>%3:%4</td>")
473-
.arg(inputFiles[j].size()).arg(j + 1).arg(tr("Subtask Dependence Status")).arg(score[j].back() == -1 ? tr("Success") : tr("Failed"));
474+
.arg(inputFiles[j].size()).arg(j + 1).arg(tr("Subtask Dependence Status")).arg(statusRankingText(score[j].back()));
474475
}
475476

476477
htmlCode += QString("<td>%1</td>").arg(inputFiles[j][k]);

globaltype.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,4 @@ enum ResultState { CorrectAnswer, WrongAnswer, PartlyCorrect,
3838
SpecialJudgeRunTimeError, Skipped, InteractorError,
3939
PresentationError, OutputLimitExceeded
4040
};
41-
42-
inline int stateToStatus(ResultState in)
43-
{
44-
if (in == CorrectAnswer) return 2;
45-
46-
if (in == PartlyCorrect) return 1;
47-
48-
return 0;
49-
}
50-
51-
5241
#endif // GLOBALTYPE_H

judgingdialog.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "contest.h"
3030
#include "task.h"
3131
#include "judgesharedvariables.h"
32+
#include "globaltype.h"
33+
#include "subtaskdependencelib.h"
3234
#include <QScrollBar>
3335

3436
JudgingDialog::JudgingDialog(QWidget *parent) :
@@ -204,7 +206,7 @@ void JudgingDialog::singleCaseFinished(int progress, int x, int y, int result, i
204206
}
205207
else
206208
{
207-
scoretext = tr(" %1 Pt").arg(abs(scoreGot));
209+
scoretext = tr(" %1 Pt").arg(qAbs(scoreGot));
208210
scorecharFormat.setForeground(QBrush(Qt::darkYellow));
209211
}
210212

@@ -325,29 +327,27 @@ void JudgingDialog::singleSubtaskDependenceFinished(int x, int y, int status)
325327
QTextCharFormat ratioFormat;
326328
charFormat.setFontPointSize(9);
327329
ratioFormat.setFontPointSize(9);
328-
QString text;
330+
QString text = statusRankingText(status);
329331

330-
if (status >= 2)
332+
if (status >= mxDependValue)
331333
{
332-
text = QString(tr("Pure"));
333334
charFormat.setForeground(QBrush(Qt::lightGray));
334335
ratioFormat.setForeground(QBrush(Qt::green));
335336
}
336-
else if (status <= 0)
337+
else if (status < 0)
337338
{
338-
text = QString(tr("Lost"));
339339
charFormat.setForeground(QBrush(Qt::red));
340340
ratioFormat.setForeground(QBrush(Qt::red));
341341
ratioFormat.setFontWeight(QFont::Bold);
342342
}
343343
else
344344
{
345-
text = QString(tr("Far"));
346-
charFormat.setForeground(QBrush(Qt::lightGray));
347-
ratioFormat.setForeground(QBrush(Qt::cyan));
345+
charFormat.setForeground(QBrush(Qt::darkYellow));
346+
ratioFormat.setForeground(QBrush(Qt::darkYellow));
347+
ratioFormat.setFontWeight(QFont::Bold);
348348
}
349349

350-
cursor->insertText(tr("Subtask Dependence %1.%2: ").arg(x + 1).arg(y + 1), charFormat);
350+
cursor->insertText(tr("Subtask Dependence %1: #%2: ").arg(x + 1).arg(y), charFormat);
351351
cursor->insertText(text, ratioFormat);
352352
QScrollBar *bar = ui->logViewer->verticalScrollBar();
353353

judgingthread.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ auto JudgingThread::getScore() const -> int
144144
return score;
145145
}
146146

147+
auto JudgingThread::getFullScore() const -> int
148+
{
149+
return fullScore;
150+
}
151+
147152
auto JudgingThread::getJudgeTimes() const -> int
148153
{
149154
return judgedTimes;

judgingthread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class JudgingThread : public QThread
5252
int getTimeUsed() const;
5353
int getMemoryUsed() const;
5454
int getScore() const;
55+
int getFullScore() const;
5556
int getJudgeTimes() const;
5657
ResultState getResult() const;
5758
const QString &getMessage() const;

lemon.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ HEADERS += lemon.h \
7676
exttestcasemodifierdialog.h \
7777
exttestcasetable.h \
7878
exttestcaseupdaterdialog.h \
79+
subtaskdependencelib.h \
7980
visualsettings.h \
8081
task.h \
8182
testcase.h \

lemon_zh_CN.qm

-259 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)