Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/base/LemonUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace Lemon::detail {
} else
return -1;
}
inline qint64 jsonReadHelper(qint64 &val, const QJsonValue &jval) {
if (jval.isDouble()) {
val = jval.toInteger();
return 0;
} else
return -1;
}
inline int jsonReadHelper(bool &val, const QJsonValue &jval) {
if (jval.isBool()) {
val = jval.toBool();
Expand Down
4 changes: 2 additions & 2 deletions src/component/exportutil/exportutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ auto ExportUtil::getContestantHtmlCode(Contest *contest, Contestant *contestant,
QList<QList<ResultState>> result = contestant->getResult(i);
QList<QStringList> message = contestant->getMessage(i);
QList<QList<int>> timeUsed = contestant->getTimeUsed(i);
QList<QList<int>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<qint64>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<int>> score = contestant->getScore(i);

for (int j = 0; j < inputFiles.size(); j++) {
Expand Down Expand Up @@ -493,7 +493,7 @@ auto ExportUtil::getSmallerContestantHtmlCode(Contest *contest, Contestant *cont
QList<QList<ResultState>> result = contestant->getResult(i);
QList<QStringList> message = contestant->getMessage(i);
QList<QList<int>> timeUsed = contestant->getTimeUsed(i);
QList<QList<int>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<qint64>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<int>> score = contestant->getScore(i);

for (int j = 0; j < inputFiles.size(); j++) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/contestant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ auto Contestant::getScore(int index) const -> const QList<QList<int>> & { return

auto Contestant::getTimeUsed(int index) const -> const QList<QList<int>> & { return timeUsed[index]; }

auto Contestant::getMemoryUsed(int index) const -> const QList<QList<int>> & { return memoryUsed[index]; }
auto Contestant::getMemoryUsed(int index) const -> const QList<QList<qint64>> & { return memoryUsed[index]; }

auto Contestant::getJudingTime() const -> QDateTime { return judgingTime; }

Expand All @@ -60,7 +60,7 @@ void Contestant::setScore(int index, const QList<QList<int>> &_score) { score[in

void Contestant::setTimeUsed(int index, const QList<QList<int>> &_timeUsed) { timeUsed[index] = _timeUsed; }

void Contestant::setMemoryUsed(int index, const QList<QList<int>> &_memoryUsed) {
void Contestant::setMemoryUsed(int index, const QList<QList<qint64>> &_memoryUsed) {
memoryUsed[index] = _memoryUsed;
}

Expand All @@ -76,7 +76,7 @@ void Contestant::addTask() {
message.append(QList<QStringList>());
score.append(QList<QList<int>>());
timeUsed.append(QList<QList<int>>());
memoryUsed.append(QList<QList<int>>());
memoryUsed.append(QList<QList<qint64>>());
}

void Contestant::deleteTask(int index) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/contestant.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Contestant : public QObject {
const QList<QStringList> &getMessage(int) const;
const QList<QList<int>> &getScore(int) const;
const QList<QList<int>> &getTimeUsed(int) const;
const QList<QList<int>> &getMemoryUsed(int) const;
const QList<QList<qint64>> &getMemoryUsed(int) const;
QDateTime getJudingTime() const;
int getTaskScore(int) const;
int getTotalScore() const;
Expand All @@ -46,7 +46,7 @@ class Contestant : public QObject {
void setMessage(int, const QList<QStringList> &);
void setScore(int, const QList<QList<int>> &);
void setTimeUsed(int, const QList<QList<int>> &);
void setMemoryUsed(int, const QList<QList<int>> &);
void setMemoryUsed(int, const QList<QList<qint64>> &);
void setJudgingTime(QDateTime);

int writeToJson(QJsonObject &);
Expand All @@ -64,7 +64,7 @@ class Contestant : public QObject {
QList<QList<QStringList>> message;
QList<QList<QList<int>>> score;
QList<QList<QList<int>>> timeUsed;
QList<QList<QList<int>>> memoryUsed;
QList<QList<QList<qint64>>> memoryUsed;
QDateTime judgingTime;

// QList<TaskResult> taskResults;
Expand Down
4 changes: 2 additions & 2 deletions src/core/judgingthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void JudgingThread::setInterpreterAsWatcher(bool use) { interpreterAsWatcher = u

auto JudgingThread::getTimeUsed() const -> int { return timeUsed; }

auto JudgingThread::getMemoryUsed() const -> int { return memoryUsed; }
auto JudgingThread::getMemoryUsed() const -> qint64 { return memoryUsed; }

auto JudgingThread::getScore() const -> int { return score; }

Expand Down Expand Up @@ -828,4 +828,4 @@ void JudgingThread::run() {
judgeAnswersOnlyTask();
break;
}
}
}
4 changes: 2 additions & 2 deletions src/core/judgingthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class JudgingThread : public QThread {
void setRawMemoryLimit(int);
void setInterpreterAsWatcher(bool);
int getTimeUsed() const;
int getMemoryUsed() const;
qint64 getMemoryUsed() const;
int getScore() const;
int getFullScore() const;
int getJudgeTimes() const;
Expand Down Expand Up @@ -72,7 +72,7 @@ class JudgingThread : public QThread {
int memoryLimit{};
int rawMemoryLimit{};
int timeUsed;
int memoryUsed;
qint64 memoryUsed;
int score{};
int judgedTimes;
ResultState result;
Expand Down
5 changes: 3 additions & 2 deletions src/core/processrunner_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ ProcessRunnerResult WinProcessRunner::run() {
if (config.memoryLimit != -1) {
GetProcessMemoryInfo(pi.hProcess, (PROCESS_MEMORY_COUNTERS *)&memoryInfo, sizeof(memoryInfo));

if (qMax(memoryInfo.PrivateUsage, memoryInfo.PeakWorkingSetSize) > config.memoryLimit * 1024 * 1024) {
if (qMax(memoryInfo.PrivateUsage, memoryInfo.PeakWorkingSetSize) >
1ll * config.memoryLimit * 1024 * 1024) {
TerminateProcess(pi.hProcess, 0);

res.score = 0;
Expand All @@ -292,7 +293,7 @@ ProcessRunnerResult WinProcessRunner::run() {
GetProcessMemoryInfo(pi.hProcess, (PROCESS_MEMORY_COUNTERS *)&memoryInfo, sizeof(memoryInfo));

if (qMax(memoryInfo.PrivateUsage, memoryInfo.PeakWorkingSetSize) >
config.memoryLimit * 1024U * 1024) {
1ll * config.memoryLimit * 1024 * 1024) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不如把 config.memoryLimit 一起改成 i64

Copy link
Copy Markdown
Contributor Author

@ZnPdCo ZnPdCo Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改动量是不是稍微有些大了,不是很想去改,要改也另开一个 pr 去改吧

TerminateProcess(pi.hProcess, 0);
res.score = 0;
res.result = MemoryLimitExceeded;
Expand Down
2 changes: 1 addition & 1 deletion src/core/taskjudger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ int TaskJudger::judge() {

for (int i = 0; i < task->getTestCaseList().size(); i++) {
timeUsed.append(QList<int>());
memoryUsed.append(QList<int>());
memoryUsed.append(QList<qint64>());
score.append(QList<int>());
result.append(QList<ResultState>());
overallStatus.append(maxDependValue);
Expand Down
2 changes: 1 addition & 1 deletion src/core/taskjudger.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TaskJudger : public QObject {
QProcessEnvironment environment;
QList<int> overallStatus;
QList<QList<int>> timeUsed;
QList<QList<int>> memoryUsed;
QList<QList<qint64>> memoryUsed;
QList<QList<int>> score;
QList<QList<ResultState>> result;
QList<QStringList> message;
Expand Down
2 changes: 1 addition & 1 deletion src/detaildialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void DetailDialog::refreshViewer(Contest *_contest, Contestant *_contestant) {
QList<QList<ResultState>> result = contestant->getResult(i);
QList<QStringList> message = contestant->getMessage(i);
QList<QList<int>> timeUsed = contestant->getTimeUsed(i);
QList<QList<int>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<qint64>> memoryUsed = contestant->getMemoryUsed(i);
QList<QList<int>> score = contestant->getScore(i);

for (int j = 0; j < inputFiles.size(); j++) {
Expand Down
2 changes: 1 addition & 1 deletion src/judgingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void JudgingDialog::judgeAll() {
}

void JudgingDialog::singleCaseFinished(QString contestantName, int progress, int x, int y, int result,
int scoreGot, int timeUsed, int memoryUsed) {
int scoreGot, int timeUsed, qint64 memoryUsed) {
bool isOnMaxValue =
ui->logViewer->verticalScrollBar()->value() == ui->logViewer->verticalScrollBar()->maximum();
QTextBlockFormat blockFormat;
Expand Down
2 changes: 1 addition & 1 deletion src/judgingdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class JudgingDialog : public QDialog {

public slots:
void dialogAlert(const QString &);
void singleCaseFinished(QString, int, int, int, int, int, int, int);
void singleCaseFinished(QString, int, int, int, int, int, int, qint64);
void singleSubtaskDependenceFinished(int, int, int);
void taskJudgingStarted(const QString &);
void taskJudgedDisplay(const QString &, const QList<QList<int>> &, const int);
Expand Down
Loading