add resolver page
This commit is contained in:
parent
97a56145b2
commit
fe9b899232
8 changed files with 1673 additions and 0 deletions
5
resources/bootstrap/bootstrap.min.css
vendored
Executable file
5
resources/bootstrap/bootstrap.min.css
vendored
Executable file
File diff suppressed because one or more lines are too long
470
resources/contest.json
Normal file
470
resources/contest.json
Normal file
|
@ -0,0 +1,470 @@
|
|||
{
|
||||
"problem_sub":[6, 3, 3],
|
||||
"sub_frozen":[6, 3, 4],
|
||||
"problems":{
|
||||
"1":{
|
||||
"1":30,
|
||||
"2":10,
|
||||
"3":11,
|
||||
"4":17,
|
||||
"5":10,
|
||||
"6":22
|
||||
},
|
||||
"2":{
|
||||
"1":20,
|
||||
"2":45,
|
||||
"3":35
|
||||
},
|
||||
"3":{
|
||||
"1":50,
|
||||
"2":15,
|
||||
"3":35
|
||||
}
|
||||
},
|
||||
"users":{
|
||||
"1":{
|
||||
"username":"user1",
|
||||
"name":"Nguyen Van AA",
|
||||
"school":"School A",
|
||||
"last_submission":13,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":-1,
|
||||
"2":-1,
|
||||
"3":-1,
|
||||
"4":-1,
|
||||
"5":-1,
|
||||
"6":0
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":0,
|
||||
"2":0,
|
||||
"3":0,
|
||||
"4":0,
|
||||
"5":0,
|
||||
"6":0
|
||||
}
|
||||
},
|
||||
"2":{
|
||||
"points":{
|
||||
"1":20,
|
||||
"2":1,
|
||||
"3":0
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":20,
|
||||
"2":0,
|
||||
"3":0
|
||||
}
|
||||
},
|
||||
"3":{
|
||||
"points":{
|
||||
"1":30,
|
||||
"2":15,
|
||||
"3":0
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":29,
|
||||
"2":0,
|
||||
"3":0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"2":{
|
||||
"username":"user2",
|
||||
"name":"Nguyen Van AB",
|
||||
"school":"School B",
|
||||
"last_submission":37,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":-1,
|
||||
"2":-1,
|
||||
"3":-1,
|
||||
"4":-1,
|
||||
"5":-1,
|
||||
"6":0
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":0,
|
||||
"2":4,
|
||||
"3":5,
|
||||
"4":0,
|
||||
"5":7,
|
||||
"6":0
|
||||
}
|
||||
},
|
||||
"2":{
|
||||
"points":{
|
||||
"1":0,
|
||||
"2":21,
|
||||
"3":35
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":0,
|
||||
"2":1,
|
||||
"3":0
|
||||
}
|
||||
},
|
||||
"3":{
|
||||
"points":{
|
||||
"1":50,
|
||||
"2":15,
|
||||
"3":19
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":45,
|
||||
"2":1,
|
||||
"3":1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"3":{
|
||||
"username":"user3",
|
||||
"name":"Nguyen Van AC",
|
||||
"school":"School C",
|
||||
"last_submission":21,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":14,
|
||||
"2":7,
|
||||
"3":0,
|
||||
"4":17,
|
||||
"5":10,
|
||||
"6":22
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":5,
|
||||
"2":5,
|
||||
"3":0,
|
||||
"4":1,
|
||||
"5":10,
|
||||
"6":4
|
||||
}
|
||||
},
|
||||
"3":{
|
||||
"points":{
|
||||
"1":-1,
|
||||
"2":15,
|
||||
"3":35
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":50,
|
||||
"2":15,
|
||||
"3":35
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"4":{
|
||||
"username":"user4",
|
||||
"name":"Nguyen Van AD",
|
||||
"school":"School D",
|
||||
"last_submission":79,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":30,
|
||||
"2":10,
|
||||
"3":3,
|
||||
"4":17,
|
||||
"5":4,
|
||||
"6":10
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":19,
|
||||
"2":8,
|
||||
"3":0,
|
||||
"4":17,
|
||||
"5":2,
|
||||
"6":7
|
||||
}
|
||||
},
|
||||
"2":{
|
||||
"points":{
|
||||
"1":20,
|
||||
"2":45,
|
||||
"3":35
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":20,
|
||||
"2":45,
|
||||
"3":35
|
||||
}
|
||||
},
|
||||
"3":{
|
||||
"points":{
|
||||
"1":50,
|
||||
"2":15,
|
||||
"3":35
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":50,
|
||||
"2":9,
|
||||
"3":11
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"5":{
|
||||
"username":"user5",
|
||||
"name":"Nguyen Van AE",
|
||||
"school":"School E",
|
||||
"last_submission":36,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":30,
|
||||
"2":7,
|
||||
"3":11,
|
||||
"4":17,
|
||||
"5":10,
|
||||
"6":1
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":3,
|
||||
"2":7,
|
||||
"3":0,
|
||||
"4":1,
|
||||
"5":10,
|
||||
"6":0
|
||||
}
|
||||
},
|
||||
"2":{
|
||||
"points":{
|
||||
"1":20,
|
||||
"2":45,
|
||||
"3":0
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":11,
|
||||
"2":0,
|
||||
"3":0
|
||||
}
|
||||
},
|
||||
"3":{
|
||||
"points":{
|
||||
"1":15,
|
||||
"2":15,
|
||||
"3":35
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":3,
|
||||
"2":10,
|
||||
"3":15
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"6":{
|
||||
"username":"user6",
|
||||
"name":"Nguyen Van AF",
|
||||
"school":"School F",
|
||||
"last_submission":17,
|
||||
"problems":{
|
||||
}
|
||||
},
|
||||
"7":{
|
||||
"username":"user7",
|
||||
"name":"Nguyen Van AG",
|
||||
"school":"School G",
|
||||
"last_submission":91,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":28,
|
||||
"2":1,
|
||||
"3":11,
|
||||
"4":17,
|
||||
"5":6,
|
||||
"6":22
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":7,
|
||||
"2":0,
|
||||
"3":1,
|
||||
"4":9,
|
||||
"5":1,
|
||||
"6":7
|
||||
}
|
||||
},
|
||||
"2":{
|
||||
"points":{
|
||||
"1":20,
|
||||
"2":45,
|
||||
"3":24
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":20,
|
||||
"2":13,
|
||||
"3":0
|
||||
}
|
||||
},
|
||||
"3":{
|
||||
"points":{
|
||||
"1":29,
|
||||
"2":13,
|
||||
"3":35
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":10,
|
||||
"2":0,
|
||||
"3":35
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"8":{
|
||||
"username":"user8",
|
||||
"name":"Nguyen Van AH",
|
||||
"school":"School H",
|
||||
"last_submission":60,
|
||||
"problems":{
|
||||
}
|
||||
},
|
||||
"9":{
|
||||
"username":"user9",
|
||||
"name":"Nguyen Van AI",
|
||||
"school":"School I",
|
||||
"last_submission":89,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":17,
|
||||
"2":10,
|
||||
"3":1,
|
||||
"4":17,
|
||||
"5":5,
|
||||
"6":13
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":0,
|
||||
"2":10,
|
||||
"3":0,
|
||||
"4":3,
|
||||
"5":4,
|
||||
"6":11
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"10":{
|
||||
"username":"user10",
|
||||
"name":"Nguyen Van AJ",
|
||||
"school":"School J",
|
||||
"last_submission":10,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":30,
|
||||
"2":7,
|
||||
"3":5,
|
||||
"4":0,
|
||||
"5":7,
|
||||
"6":17
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":12,
|
||||
"2":1,
|
||||
"3":0,
|
||||
"4":0,
|
||||
"5":3,
|
||||
"6":0
|
||||
}
|
||||
},
|
||||
"2":{
|
||||
"points":{
|
||||
"1":20,
|
||||
"2":45,
|
||||
"3":35
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":20,
|
||||
"2":0,
|
||||
"3":35
|
||||
}
|
||||
},
|
||||
"3":{
|
||||
"points":{
|
||||
"1":50,
|
||||
"2":0,
|
||||
"3":35
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":12,
|
||||
"2":0,
|
||||
"3":31
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"11":{
|
||||
"username":"user11",
|
||||
"name":"Nguyen Van AK",
|
||||
"school":"School K",
|
||||
"last_submission":61,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":30,
|
||||
"2":10,
|
||||
"3":11,
|
||||
"4":17,
|
||||
"5":10,
|
||||
"6":0
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":26,
|
||||
"2":7,
|
||||
"3":0,
|
||||
"4":14,
|
||||
"5":2,
|
||||
"6":0
|
||||
}
|
||||
},
|
||||
"2":{
|
||||
"points":{
|
||||
"1":20,
|
||||
"2":45,
|
||||
"3":23
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":12,
|
||||
"2":45,
|
||||
"3":1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"12":{
|
||||
"username":"user12",
|
||||
"name":"Nguyen Van AL",
|
||||
"school":"School L",
|
||||
"last_submission":49,
|
||||
"problems":{
|
||||
"1":{
|
||||
"points":{
|
||||
"1":30,
|
||||
"2":10,
|
||||
"3":0,
|
||||
"4":17,
|
||||
"5":0,
|
||||
"6":1
|
||||
},
|
||||
"frozen_points":{
|
||||
"1":19,
|
||||
"2":1,
|
||||
"3":0,
|
||||
"4":10,
|
||||
"5":0,
|
||||
"6":0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
395
resources/resolver.css
Normal file
395
resources/resolver.css
Normal file
|
@ -0,0 +1,395 @@
|
|||
/*
|
||||
main.css
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
reset bootstrap
|
||||
*/
|
||||
::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
:root {
|
||||
scrollbar-width: none;
|
||||
/* color */
|
||||
--primary_color : #EFF5F5;
|
||||
--secondary_color : #D6E4E5;
|
||||
--wa : #EB6440;
|
||||
--partially : #fff133;
|
||||
--ac : #80ED99;
|
||||
--frozen : #497174;
|
||||
--untouched : #A7BBC7;
|
||||
--selected : rgb(206, 75, 199);
|
||||
--theme-text-color : black;
|
||||
--theme-background-color : white;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
margin-bottom: 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
/*
|
||||
common
|
||||
*/
|
||||
.app {
|
||||
color: white;
|
||||
background-color: var(--theme-background-color);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.item {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.rank,
|
||||
.content,
|
||||
.problems li {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.score,
|
||||
.penalty {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.rank,
|
||||
.score,
|
||||
.penalty {
|
||||
font-size: 35px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 83px;
|
||||
}
|
||||
|
||||
.rank-list-item {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
padding: 10px;
|
||||
position: relative;
|
||||
background: transparent;
|
||||
-moz-transition-duration: 1s;
|
||||
-webkit-transition-duration: 1s;
|
||||
-ms-transition-duration: 1s;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.untouched {
|
||||
background-color: var(--untouched);
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.pro-score.untouched {
|
||||
color: var(--theme-text-color);
|
||||
}
|
||||
|
||||
.frozen {
|
||||
background-color: var(--frozen);
|
||||
}
|
||||
|
||||
.failed,
|
||||
.WA {
|
||||
background-color: var(--wa);
|
||||
}
|
||||
|
||||
.partially {
|
||||
background-color: var(--partially);
|
||||
/* border: 2px solid var(--partially); */
|
||||
}
|
||||
|
||||
.ac {
|
||||
background-color: var(--ac);
|
||||
}
|
||||
|
||||
.selected {
|
||||
background-color: var(--selected);
|
||||
}
|
||||
|
||||
.p-content.selected {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.uncover {
|
||||
animation: flashing 300ms infinite;
|
||||
-webkit-animation: flashing 30ms infinite;
|
||||
/*Safari and Chrome*/
|
||||
}
|
||||
|
||||
@keyframes flashing {
|
||||
from {
|
||||
background-color: #8a6d3b
|
||||
}
|
||||
|
||||
to {
|
||||
background-color: #BD995B
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes flashing {
|
||||
|
||||
/*Safari and Chrome*/
|
||||
from {
|
||||
background-color: #8a6d3b
|
||||
}
|
||||
|
||||
to {
|
||||
background-color: #BD995B
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
index
|
||||
*/
|
||||
|
||||
.show-rank {
|
||||
opacity: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
background-color: black;
|
||||
z-index: -1;
|
||||
-moz-transition-duration: 1s;
|
||||
-webkit-transition-duration: 1s;
|
||||
-ms-transition-duration: 1s;
|
||||
}
|
||||
|
||||
.show-rank .name-show {
|
||||
bottom: 60px;
|
||||
font-size: 40px;
|
||||
font-weight: bolder;
|
||||
position: absolute;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.show-rank .rank-show {
|
||||
bottom: 120px;
|
||||
position: absolute;
|
||||
font-size: 60px;
|
||||
font-weight: bolder;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.show-rank .school-show {
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
font-size: 30px;
|
||||
font-weight: bolder;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.rank {
|
||||
width: 58px;
|
||||
height: 58px;
|
||||
font-size: 35px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 83px;
|
||||
margin-right: 15px;
|
||||
color: var(--theme-text-color);
|
||||
}
|
||||
|
||||
.info-container .name {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
line-height: 30px;
|
||||
color: var(--theme-text-color);
|
||||
}
|
||||
|
||||
.school {
|
||||
font-size: 20px;
|
||||
font-weight: normal;
|
||||
margin-bottom: 5px;
|
||||
line-height: 30px;
|
||||
margin-left: 8px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.problems {
|
||||
list-style-type: none;
|
||||
padding: 5px 0;
|
||||
font-size: 12px;
|
||||
border-radius: 10px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.problems .item {
|
||||
padding: 4px;
|
||||
margin: 0 5px;
|
||||
width: 70px;
|
||||
text-align: center;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.problems .item .p-content {
|
||||
padding: 0px 0;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
border-radius: 10px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.score {
|
||||
font-weight: bold;
|
||||
width: 70px;
|
||||
color: var(--theme-text-color);
|
||||
}
|
||||
|
||||
.penalty {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.problem-container {
|
||||
display: flex;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.prob-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-right: 40px;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pro-score {
|
||||
position: relative;
|
||||
font-size: 24px;
|
||||
line-height: 24px;
|
||||
font-weight: bolder;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 80px;
|
||||
cursor: pointer;
|
||||
color: var(--theme-text-color);
|
||||
border-radius: 10px 0 0 10px;
|
||||
}
|
||||
|
||||
.pro-score:hover {
|
||||
/* border: 2px solid white; */
|
||||
/* padding: 2px 2px; */
|
||||
/* border-radius: 10px 0 0 10px; */
|
||||
}
|
||||
|
||||
.pro-score.partially {
|
||||
border: 4px solid var(--partially);
|
||||
}
|
||||
|
||||
.pro-score.ac {
|
||||
border: 4px solid #2da728;
|
||||
}
|
||||
|
||||
.pro-score.failed {
|
||||
border: 4px solid #e21919;
|
||||
}
|
||||
|
||||
.pro-score.frozen {
|
||||
border: 4px solid #004d64;
|
||||
}
|
||||
|
||||
.problems .item:hover {
|
||||
border: 2px solid white;
|
||||
padding: 2px 2px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.pro-score.selected {
|
||||
border: 4px solid white;
|
||||
padding: 0 0;
|
||||
border-radius: 10px 0 0 10px;
|
||||
}
|
||||
|
||||
.problems .item.selected {
|
||||
border: 4px solid white;
|
||||
padding: 0 0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.hidden-board {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.info-bar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 0;
|
||||
border-bottom: 2px solid var(--theme-text-color);
|
||||
z-index: 1000;
|
||||
font-weight: bolder;
|
||||
background-color: var(--theme-background-color);
|
||||
}
|
||||
|
||||
.info-bar .rank {
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
font-weight: lighter;
|
||||
height: 20px;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
|
||||
.info-bar .name {
|
||||
font-size: 20px;
|
||||
font-weight: lighter;
|
||||
height: 20px;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
color: var(--theme-text-color);
|
||||
}
|
||||
|
||||
.info-bar .score {
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
font-weight: lighter;
|
||||
height: 20px;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
|
||||
.sticky {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
.info-container {
|
||||
display: flex;
|
||||
color: var(--theme-text-color);
|
||||
}
|
||||
|
||||
.background-primary {
|
||||
background-color: var(--primary_color);
|
||||
}
|
||||
.background-secondary {
|
||||
background-color: var(--secondary_color);
|
||||
}
|
318
resources/resolver.js
Normal file
318
resources/resolver.js
Normal file
|
@ -0,0 +1,318 @@
|
|||
function Resolver(problem_sub, sub_frozen, problems, users) {
|
||||
this.problem_sub = problem_sub;
|
||||
this.sub_frozen = sub_frozen;
|
||||
this.problems = problems;
|
||||
this.users = users;
|
||||
this.frozen_seconds = 200;
|
||||
this.operations = [];
|
||||
this.frozen_op = 0;
|
||||
this.isshow = [];
|
||||
this.delay = false;
|
||||
}
|
||||
|
||||
Resolver.prototype.status = function (problem) {
|
||||
if (problem.old_verdict == 'NA' && problem.new_verdict == 'NA') {
|
||||
return 'untouched';
|
||||
} else if (problem.old_verdict == 'AC') {
|
||||
return 'ac';
|
||||
} else if (problem.old_verdict == 'PA' && problem.new_verdict == 'NA') {
|
||||
return 'partially';
|
||||
} else if (problem.new_verdict == 'NA' && problem.old_verdict == 'WA') {
|
||||
return 'failed';
|
||||
} else {
|
||||
return "frozen";
|
||||
}
|
||||
}
|
||||
|
||||
Resolver.prototype.substatus = function (problem, subproblem) {
|
||||
if (problem.old_verdict == 'NA' && problem.new_verdict == 'NA') {
|
||||
return 'untouched';
|
||||
} else if (problem[subproblem].old_verdict == 'AC') {
|
||||
return 'ac';
|
||||
} else if (problem[subproblem].old_verdict == 'PA' && problem.new_verdict == 'NA') {
|
||||
return 'partially';
|
||||
} else if (problem[subproblem].old_verdict == 'WA' && problem.new_verdict == 'NA') {
|
||||
return 'failed';
|
||||
}
|
||||
else {
|
||||
return 'frozen';
|
||||
}
|
||||
}
|
||||
|
||||
Resolver.prototype.pointstatus = function (point, problem, sub) {
|
||||
if (sub == undefined) {
|
||||
if (point == 100) return 'AC';
|
||||
if (point == 0) return 'WA';
|
||||
return 'PA';
|
||||
}
|
||||
if (point == this.problems[problem][sub]) return 'AC';
|
||||
if (point == 0) return 'WA';
|
||||
return 'PA';
|
||||
}
|
||||
|
||||
Resolver.prototype.calcOperations = function () {
|
||||
this.rank = {};
|
||||
this.users_cnt = Object.keys(this.users).length;
|
||||
for (let id = 1; id <= this.users_cnt; id++) {
|
||||
this.rank[id] = {
|
||||
'user_id': id,
|
||||
'score': 0,
|
||||
'rank_show': -1,
|
||||
'last_submission': this.users[id].last_submission,
|
||||
};
|
||||
this.rank[id].problem = {}
|
||||
for (let i = 1; i <= this.problem_sub.length; i++) {
|
||||
this.rank[id].problem[i] = {
|
||||
'old_point': 0,
|
||||
'new_point': 0,
|
||||
'old_verdict': 'NA',
|
||||
'new_verdict': 'NA',
|
||||
}
|
||||
for (let j = 1; j <= this.problem_sub[i - 1]; j++) {
|
||||
this.rank[id].problem[i][j] = {
|
||||
'old_point': 0,
|
||||
'new_point': 0,
|
||||
'old_verdict': 'NA',
|
||||
'new_verdict': 'NA'
|
||||
};
|
||||
}
|
||||
}
|
||||
for (let problemid in this.users[id].problems) {
|
||||
for (let j = 1; j <= this.problem_sub[problemid - 1]; j++) {
|
||||
if (j < this.sub_frozen[problemid - 1]) {
|
||||
this.rank[id].problem[problemid][j].old_point = this.users[id].problems[problemid].frozen_points[j];
|
||||
this.rank[id].problem[problemid].old_point += this.rank[id].problem[problemid][j].old_point;
|
||||
this.rank[id].problem[problemid][j].old_verdict = this.pointstatus(this.users[id].problems[problemid].frozen_points[j], problemid, j);
|
||||
if (this.users[id].problems[problemid].points[j] != -1) {
|
||||
this.rank[id].problem[problemid][j].new_point = this.users[id].problems[problemid].points[j];
|
||||
this.rank[id].problem[problemid].new_point += this.rank[id].problem[problemid][j].new_point;
|
||||
this.rank[id].problem[problemid][j].new_verdict = this.pointstatus(this.users[id].problems[problemid].points[j], problemid, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.rank[id].problem[problemid].old_verdict = this.pointstatus(this.rank[id].problem[problemid].old_point);
|
||||
this.rank[id].score += this.rank[id].problem[problemid].old_point;
|
||||
if (this.users[id].problems[problemid].points[1] != -1) {
|
||||
this.rank[id].problem[problemid].new_verdict = this.pointstatus(this.rank[id].problem[problemid].new_point);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.rank_frozen = $.extend(true, [], this.rank);
|
||||
var uids = Object.keys(this.rank);
|
||||
this.rankarr = [];
|
||||
for (let key in uids) {
|
||||
this.rankarr.push(this.rank[uids[key]]);
|
||||
}
|
||||
this.rankarr.sort(function (a, b) {
|
||||
if (a.score != b.score) {
|
||||
return (b.score - a.score);
|
||||
} else {
|
||||
return (a.last_submission - b.last_submission);
|
||||
}
|
||||
});
|
||||
|
||||
for (let i = 0; i < this.rankarr.length; i++) {
|
||||
this.rankarr[i].rank_show = i + 1;
|
||||
this.rank[this.rankarr[i].user_id].rank_show = i + 1;
|
||||
this.rank_frozen[this.rankarr[i].user_id].rank_show = i + 1;
|
||||
}
|
||||
console.log(this.rank_frozen);
|
||||
for (let i = this.rankarr.length - 1; i >= 0; i--) {
|
||||
var flag = true;
|
||||
while (flag) {
|
||||
flag = false;
|
||||
for (let j = 1; j <= this.problem_sub.length; j++) {
|
||||
if (this.status(this.rankarr[i].problem[j]) == 'frozen') {
|
||||
frozen_op = true;
|
||||
flag = true;
|
||||
for (let sub = 1; sub < this.sub_frozen[j - 1]; sub++) {
|
||||
if (this.rankarr[i].problem[j][sub].old_verdict == 'AC') continue;
|
||||
var op = {
|
||||
id: this.operations.length,
|
||||
type: 'sub',
|
||||
frozen: 'no',
|
||||
user_id: this.rankarr[i].user_id,
|
||||
problem_index: j,
|
||||
problem_sub: sub,
|
||||
old_point: this.rankarr[i].problem[j][sub].old_point,
|
||||
new_point: this.rankarr[i].problem[j][sub].new_point,
|
||||
old_verdict: this.rankarr[i].problem[j][sub].old_verdict,
|
||||
new_verdict: this.rankarr[i].problem[j][sub].new_verdict,
|
||||
};
|
||||
var tmp = this.rankarr[i];
|
||||
tmp.problem[j][sub].old_point = tmp.problem[j][sub].new_point;
|
||||
tmp.problem[j][sub].new_point = 0;
|
||||
tmp.problem[j][sub].old_verdict = tmp.problem[j][sub].new_verdict;
|
||||
tmp.problem[j][sub].new_verdict = 'NA';
|
||||
this.operations.push(op);
|
||||
}
|
||||
var op = {
|
||||
id: this.operations.length,
|
||||
type: 'problem',
|
||||
frozen: 'no',
|
||||
user_id: this.rankarr[i].user_id,
|
||||
problem_index: j,
|
||||
old_point: this.rankarr[i].problem[j].old_point,
|
||||
new_point: this.rankarr[i].problem[j].new_point,
|
||||
old_verdict: this.rankarr[i].problem[j].old_verdict,
|
||||
new_verdict: this.rankarr[i].problem[j].new_verdict,
|
||||
old_rank: i + 1,
|
||||
new_rank: -1,
|
||||
};
|
||||
var tmp = this.rankarr[i];
|
||||
if (tmp.problem[j].new_point > tmp.problem[j].old_point) {
|
||||
tmp.score += tmp.problem[j].new_point - tmp.problem[j].old_point;
|
||||
}
|
||||
tmp.problem[j].old_point = tmp.problem[j].new_point;
|
||||
tmp.problem[j].new_point = 0;
|
||||
tmp.problem[j].old_verdict = tmp.problem[j].new_verdict;
|
||||
tmp.problem[j].new_verdict = 'NA';
|
||||
var k = i - 1;
|
||||
while (k >= 0 && this.rankarr[k].score < tmp.score) {
|
||||
tmp.rank_show--;
|
||||
this.rankarr[k].rank_show++;
|
||||
this.rankarr[k + 1] = this.rankarr[k];
|
||||
k--;
|
||||
}
|
||||
this.rankarr[k + 1] = tmp;
|
||||
op.new_rank = k + 2;
|
||||
this.operations.push(op);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.check = [];
|
||||
for (let i = 1; i <= this.users_cnt; i++) {
|
||||
var usercheck = [];
|
||||
for (let j = 1; j <= this.problem_sub.length; j++) {
|
||||
var cc = [];
|
||||
for (let k = 1; k <= this.sub_frozen[j - 1] - 1; k++) {
|
||||
cc.push(k);
|
||||
}
|
||||
usercheck.push(cc);
|
||||
}
|
||||
this.check.push(usercheck);
|
||||
}
|
||||
}
|
||||
|
||||
Resolver.prototype.showrank = function () {
|
||||
for (let rankid = this.rankarr.length - 1; rankid >= 0; rankid--) {
|
||||
if (this.isshow.indexOf(this.rankarr[rankid].user_id) != -1) continue;
|
||||
var ok = true;
|
||||
for (let problemid in this.users[this.rankarr[rankid].user_id].problems) {
|
||||
for (let sub = 1; sub <= this.problem_sub[problemid - 1]; sub++) {
|
||||
if (this.check[this.rankarr[rankid].user_id - 1][problemid - 1].indexOf(sub) == -1) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
var op = {
|
||||
id: this.operations.length,
|
||||
type: 'show',
|
||||
user_id: this.rankarr[rankid].user_id,
|
||||
};
|
||||
this.delay = true;
|
||||
this.isshow.push(this.rankarr[rankid].user_id);
|
||||
this.operations.push(op);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Resolver.prototype.next_operation = function () {
|
||||
if (this.delay) {
|
||||
var op = {
|
||||
id: this.operations.length,
|
||||
type: 'delay',
|
||||
};
|
||||
this.delay = false;
|
||||
this.operations.push(op);
|
||||
return true;
|
||||
}
|
||||
var isshowrank = this.showrank();
|
||||
if (isshowrank == true) return true;
|
||||
for (let i = this.rankarr.length - 1; i >= 0; i--) {
|
||||
for (let problemid = 1; problemid <= this.problem_sub.length; problemid++) {
|
||||
let ok = false;
|
||||
var id = this.rankarr[i].user_id;
|
||||
for (let cc in this.users[id].problems) {
|
||||
if (cc == problemid) ok = true;
|
||||
}
|
||||
if (ok == false) {
|
||||
continue;
|
||||
}
|
||||
for (let sub = this.sub_frozen[problemid - 1]; sub <= this.problem_sub[problemid - 1]; sub++) {
|
||||
if (this.check[this.rankarr[i].user_id - 1][problemid - 1].indexOf(sub) == -1) {
|
||||
this.operation(i, problemid, sub);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Resolver.prototype.operation = function (rankid, problemid, sub) {
|
||||
var id = this.rankarr[rankid].user_id;
|
||||
if (this.check[this.rankarr[rankid].user_id - 1][problemid - 1].indexOf(sub) != -1) return false;
|
||||
this.check[this.rankarr[rankid].user_id - 1][problemid - 1].push(sub);
|
||||
this.rankarr[rankid].problem[problemid][sub].new_point = this.users[id].problems[problemid].points[sub];
|
||||
this.rankarr[rankid].problem[problemid][sub].new_verdict = this.pointstatus(this.rankarr[rankid].problem[problemid][sub].new_point, problemid, sub);
|
||||
this.rankarr[rankid].problem[problemid].new_point =
|
||||
this.rankarr[rankid].problem[problemid].old_point + this.rankarr[rankid].problem[problemid][sub].new_point - this.rankarr[rankid].problem[problemid][sub].old_point;
|
||||
this.rankarr[rankid].problem[problemid].new_verdict = this.pointstatus(this.rankarr[rankid].problem[problemid].new_point);
|
||||
var op = {
|
||||
id: this.operations.length,
|
||||
type: 'sub',
|
||||
frozen: 'ok',
|
||||
user_id: this.rankarr[rankid].user_id,
|
||||
problem_index: problemid,
|
||||
problem_sub: sub,
|
||||
old_point: this.rankarr[rankid].problem[problemid][sub].old_point,
|
||||
new_point: this.rankarr[rankid].problem[problemid][sub].new_point,
|
||||
old_verdict: this.rankarr[rankid].problem[problemid][sub].old_verdict,
|
||||
new_verdict: this.rankarr[rankid].problem[problemid][sub].new_verdict,
|
||||
};
|
||||
var tmp = this.rankarr[rankid];
|
||||
tmp.problem[problemid][sub].old_point = tmp.problem[problemid][sub].new_point;
|
||||
tmp.problem[problemid][sub].new_point = 0;
|
||||
tmp.problem[problemid][sub].old_verdict = tmp.problem[problemid][sub].new_verdict;
|
||||
tmp.problem[problemid][sub].new_verdict = 'NA';
|
||||
this.operations.push(op);
|
||||
var op1 = {
|
||||
id: this.operations.length,
|
||||
type: 'problem',
|
||||
frozen: 'ok',
|
||||
user_id: this.rankarr[rankid].user_id,
|
||||
problem_index: problemid,
|
||||
old_point: this.rankarr[rankid].problem[problemid].old_point,
|
||||
new_point: this.rankarr[rankid].problem[problemid].new_point,
|
||||
old_verdict: this.rankarr[rankid].problem[problemid].old_verdict,
|
||||
new_verdict: this.rankarr[rankid].problem[problemid].new_verdict,
|
||||
old_rank: rankid + 1,
|
||||
new_rank: -1,
|
||||
};
|
||||
if (tmp.problem[problemid].new_point > tmp.problem[problemid].old_point) {
|
||||
tmp.score += tmp.problem[problemid].new_point - tmp.problem[problemid].old_point;
|
||||
}
|
||||
tmp.problem[problemid].old_point = tmp.problem[problemid].new_point;
|
||||
tmp.problem[problemid].new_point = 0;
|
||||
tmp.problem[problemid].old_verdict = tmp.problem[problemid].new_verdict;
|
||||
tmp.problem[problemid].new_verdict = 'NA';
|
||||
var k = rankid - 1;
|
||||
while (k >= 0 && (this.rankarr[k].score < tmp.score || (this.rankarr[k].score == tmp.score && this.rankarr[k].last_submission > tmp.last_submission))) {
|
||||
tmp.rank_show--;
|
||||
this.rankarr[k].rank_show++;
|
||||
this.rankarr[k + 1] = this.rankarr[k];
|
||||
k--;
|
||||
}
|
||||
this.rankarr[k + 1] = tmp;
|
||||
op1.new_rank = k + 2;
|
||||
this.operations.push(op1);
|
||||
return true;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue