修复一些已知的bug

This commit is contained in:
Himit_ZH 2021-06-22 11:32:15 +08:00
parent 98b84aefd5
commit 3a98b2211c
12 changed files with 88 additions and 58 deletions

View File

@ -28,8 +28,6 @@
using namespace std;
int spj(int user_output, FILE *output);
void close_file(FILE *f){
if(f != NULL){
fclose(f);
@ -37,15 +35,12 @@ void close_file(FILE *f){
}
int main(int argc, char *args[]){
if(argc != 3){
return ERROR;
}
/**
input:输入
output:样例的输出
user_output:用户的输出
**/
FILE *input = fopen(args[1], "r")
FILE *input = fopen(args[1], "r");
FILE *output = fopen(args[2], "r");
double std_out;

View File

@ -795,10 +795,10 @@ public class FileController {
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
List<ProblemDto> problemDtos = new LinkedList<>();
List<Tag> tagList = tagService.list();
HashMap<String, Long> tagMap = new HashMap<>();
List<Tag> tagList = tagService.list(new QueryWrapper<Tag>().eq("oj", "ME"));
HashMap<String, Tag> tagMap = new HashMap<>();
for (Tag tag : tagList) {
tagMap.put(tag.getName(), tag.getId());
tagMap.put(tag.getName().toUpperCase(), tag);
}
for (String key : problemInfo.keySet()) {
ImportProblemVo importProblemVo = problemVoMap.get(key);
@ -825,6 +825,18 @@ public class FileController {
}
codeTemplates.add(new CodeTemplate().setCode(code).setStatus(true).setLid(lid));
}
// 格式化标签
List<Tag> tags = new LinkedList<>();
for (String tagStr : importProblemVo.getTags()) {
Tag tag = tagMap.getOrDefault(tagStr.toUpperCase(), null);
if (tag == null) {
tags.add(new Tag().setName(tagStr).setOj("ME"));
} else {
tags.add(tag);
}
}
Problem problem = BeanUtil.mapToBean(importProblemVo.getProblem(), Problem.class, true);
if (problem.getAuthor() == null) {
problem.setAuthor(userRolesVo.getUsername());
@ -838,7 +850,7 @@ public class FileController {
problemDto.setIsSpj(importProblemVo.getIsSpj())
.setProblem(problem)
.setCodeTemplates(codeTemplates)
.setTags(importProblemVo.getTags().stream().map(tag -> new Tag().setName(tag).setId(tagMap.getOrDefault(tag, null))).collect(Collectors.toList()))
.setTags(tags)
.setLanguages(languages)
.setUploadTestcaseDir(fileDir + File.separator + key)
.setIsUploadTestCase(true)
@ -948,10 +960,10 @@ public class FileController {
HttpSession session = request.getSession();
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
List<Tag> tagList = tagService.list();
HashMap<String, Long> tagMap = new HashMap<>();
List<Tag> tagList = tagService.list(new QueryWrapper<Tag>().eq("oj", "ME"));
HashMap<String, Tag> tagMap = new HashMap<>();
for (Tag tag : tagList) {
tagMap.put(tag.getName(), tag.getId());
tagMap.put(tag.getName().toUpperCase(), tag);
}
List<ProblemDto> problemDtos = new LinkedList<>();
@ -964,6 +976,17 @@ public class FileController {
languages.add(new Language().setId(lid).setName(lang));
}
// 格式化标签
List<Tag> tags = new LinkedList<>();
for (String tagStr : qdojProblemDto.getTags()) {
Tag tag = tagMap.getOrDefault(tagStr.toUpperCase(), null);
if (tag == null) {
tags.add(new Tag().setName(tagStr).setOj("ME"));
} else {
tags.add(tag);
}
}
Problem problem = qdojProblemDto.getProblem();
if (problem.getAuthor() == null) {
problem.setAuthor(userRolesVo.getUsername());
@ -972,7 +995,7 @@ public class FileController {
problemDto.setIsSpj(qdojProblemDto.getIsSpj())
.setProblem(problem)
.setCodeTemplates(qdojProblemDto.getCodeTemplates())
.setTags(qdojProblemDto.getTags().stream().map(tag -> new Tag().setName(tag).setId(tagMap.getOrDefault(tag, null))).collect(Collectors.toList()))
.setTags(tags)
.setLanguages(languages)
.setUploadTestcaseDir(fileDir + File.separator + key + File.separator + "testcase")
.setIsUploadTestCase(true)

View File

@ -156,13 +156,15 @@ public class JudgeController {
// 管理员比赛前的提交不纳入记录
if (contest.getStatus().intValue() == Constants.Contest.STATUS_RUNNING.getCode()) {
// 先查询是否为首次可能AC提交
QueryWrapper<ContestRecord> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("cid", judge.getCid())
.eq("status", Constants.Contest.RECORD_AC.getCode())
.eq("pid", judge.getPid());
boolean FirstACAttempt = contestRecordService.count(queryWrapper) == 0;
// 方法废弃为了考虑比赛重测问题不使用字段记录是否为first AC在排行榜计算自有排序解决first AC的判断
// // 先查询是否为首次可能AC提交
// QueryWrapper<ContestRecord> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("cid", judge.getCid())
// .eq("status", Constants.Contest.RECORD_AC.getCode())
// .lt("submit_time", judge.getSubmitTime())
// .eq("pid", judge.getPid());
//
// boolean FirstACAttempt = contestRecordService.count(queryWrapper) == 0;
// 同时初始化写入contest_record表
ContestRecord contestRecord = new ContestRecord();
@ -177,11 +179,11 @@ public class JudgeController {
.setSubmitTime(judge.getSubmitTime())
// 设置比赛开始时间到提交时间之间的秒数
.setTime(DateUtil.between(contest.getStartTime(), judge.getSubmitTime(), DateUnit.SECOND));
if (FirstACAttempt) {
contestRecord.setFirstBlood(true);
} else {
contestRecord.setFirstBlood(false);
}
// if (FirstACAttempt) {
// contestRecord.setFirstBlood(true);
// } else {
// contestRecord.setFirstBlood(false);
// }
updateContestRecord = contestRecordService.saveOrUpdate(contestRecord);
}

View File

@ -3,23 +3,20 @@
<mapper namespace="top.hcode.hoj.dao.UserRecordMapper">
<select id="getACMRankList" resultType="top.hcode.hoj.pojo.vo.ACMRankVo" useCache="true">
SELECT u.uuid as uid,u.nickname,u.username,u.signature,u.avatar,
(SELECT COUNT( DISTINCT pid ) FROM user_acproblem WHERE uid =u.uuid) AS solved,
(SELECT COUNT(pid) FROM user_acproblem WHERE uid =u.uuid) AS ac,
(SELECT COUNT( DISTINCT pid ) FROM user_acproblem WHERE uid =u.uuid) AS ac,
(SELECT COUNT(uid) FROM judge WHERE uid=u.uuid AND cid=0) AS total
FROM user_info u WHERE u.status = 0
ORDER BY solved DESC,ac DESC
ORDER BY ac DESC,total ASC
</select>
<select id="getRecent7ACRank" resultType="top.hcode.hoj.pojo.vo.ACMRankVo">
SELECT u.uuid as uid,u.nickname,u.username,u.signature,u.avatar,
(SELECT COUNT( DISTINCT pid ) FROM user_acproblem WHERE uid =u.uuid
and DATE(gmt_create) >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) ) AS solved,
(SELECT COUNT(pid) FROM user_acproblem WHERE uid =u.uuid
and DATE(gmt_create) >= DATE_SUB(CURDATE(),INTERVAL 7 DAY)) AS ac,
(SELECT COUNT(uid) FROM judge WHERE uid=u.uuid AND cid=0) AS total
and DATE(gmt_create) >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) ) AS ac,
(SELECT COUNT(uid) FROM judge WHERE uid=u.uuid AND cid=0
and DATE(gmt_create) >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) )AS total
FROM user_info u WHERE u.status = 0
ORDER BY solved DESC,ac DESC LIMIT 10
ORDER BY ac DESC,total ASC LIMIT 10
</select>

View File

@ -33,9 +33,6 @@ public class ACMRankVo implements Serializable {
@ApiModelProperty(value = "头像地址")
private String avatar;
@ApiModelProperty(value = "解决问题数")
private Integer solved;
@ApiModelProperty(value = "总提交数")
private Integer total;

View File

@ -103,6 +103,8 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
int index = 0;
HashMap<String, Long> firstACMap = new HashMap<>();
for (ContestRecord contestRecord : contestRecordList) {
ACMContestRankVo ACMContestRankVo;
if (!uidMapIndex.containsKey(contestRecord.getUid())) { // 如果该用户信息没还记录
@ -141,9 +143,22 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
// 总解决题目次数ac+1
ACMContestRankVo.setAc(ACMContestRankVo.getAc() + 1);
// 判断是不是first AC
boolean isFirstAC = false;
Long time = firstACMap.getOrDefault(contestRecord.getDisplayId(), null);
if (time == null) {
isFirstAC = true;
firstACMap.put(contestRecord.getDisplayId(), contestRecord.getTime());
} else {
// 相同提交时间也是first AC
if (time.longValue() == contestRecord.getTime().longValue()) {
isFirstAC = true;
}
}
int errorNumber = (int) problemSubmissionInfo.getOrDefault("errorNum", 0);
problemSubmissionInfo.put("isAC", true);
problemSubmissionInfo.put("isFirstAC", contestRecord.getFirstBlood());
problemSubmissionInfo.put("isFirstAC", isFirstAC);
problemSubmissionInfo.put("ACTime", contestRecord.getTime());
problemSubmissionInfo.put("errorNum", errorNumber);

View File

@ -299,7 +299,7 @@ a:hover {
#nprogress .bar {
background: #66b1ff !important;
}
@media screen and (min-width: 1080px) {
@media screen and (min-width: 1050px) {
#oj-content {
margin-top: 80px;
padding: 0 4%;
@ -314,7 +314,7 @@ a:hover {
.contest-description img {
max-width: 100%;
}
@media screen and (max-width: 1080px) {
@media screen and (max-width: 1050px) {
#oj-content {
margin-top: 20px;
padding: 0 5px;

View File

@ -399,7 +399,7 @@ export default {
...mapActions(['changeModalStatus']),
page_width() {
let screenWidth = window.screen.width;
if (screenWidth < 1080) {
if (screenWidth < 1050) {
this.mobileNar = true;
} else {
this.mobileNar = false;

View File

@ -432,7 +432,7 @@ export default {
},
page_width() {
let screenWidth = window.screen.width;
if (screenWidth < 1080) {
if (screenWidth < 1050) {
this.mobileNar = true;
} else {
this.mobileNar = false;
@ -454,6 +454,13 @@ export default {
'websiteConfig',
'webLanguage',
]),
'window.screen.width'(newVal, oldVal) {
if (newVal < 1050) {
this.mobileNar = true;
} else {
this.mobileNar = false;
}
},
},
watch: {
$route() {
@ -534,14 +541,14 @@ img {
font-size: small;
}
@media screen and (min-width: 1080px) {
@media screen and (min-width: 1050px) {
.content-app {
padding-top: 20px;
padding-right: 10px;
padding-left: 210px;
}
}
@media screen and (max-width: 1080px) {
@media screen and (max-width: 1050px) {
.content-app {
padding: 0 5px;
margin-top: 20px;

View File

@ -144,8 +144,8 @@
>
</vxe-table-column>
<vxe-table-column
field="solved"
:title="$t('m.Solved')"
field="total"
:title="$t('m.Total')"
min-width="50"
align="left"
>

View File

@ -58,15 +58,7 @@
</el-tag>
</template>
</vxe-table-column>
<vxe-table-column
field="solved"
:title="$t('m.Solved')"
min-width="80"
></vxe-table-column>
<vxe-table-column
:title="$t('m.AC') + '/' + $t('m.Total')"
min-width="100"
>
<vxe-table-column field="ac" :title="$t('m.AC')" min-width="80">
<template v-slot="{ row }">
<span>
<a
@ -74,10 +66,11 @@
style="color:rgb(87, 163, 243);"
>{{ row.ac }}</a
>
<span>/{{ row.total }}</span>
</span>
</template>
</vxe-table-column>
<vxe-table-column :title="$t('m.Total')" min-width="100" field="total">
</vxe-table-column>
<vxe-table-column :title="$t('m.Rating')" min-width="80">
<template v-slot="{ row }">
<span>{{ getACRate(row.ac, row.total) }}</span>

View File

@ -647,7 +647,8 @@ CREATE TABLE `tag` (
`oj` varchar(255) DEFAULT 'ME' COMMENT '标签所属oj',
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`,`oj`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
/*Table structure for table `user_acproblem` */