# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
607521 |
2022-07-26T19:19:58 Z |
Arturgo |
Toy Train (IOI17_train) |
C++14 |
|
2000 ms |
1492 KB |
#include "train.h"
#include <deque>
#include <vector>
using namespace std;
vector<int> who_wins(vector<int> estMax, vector<int> estRecharge,
vector<int> debs, vector<int> fins) {
int nbSommets = estMax.size();
vector<int> aggregs(nbSommets, 0);
vector<int> nbMins(nbSommets, 0);
vector<int> scores(nbSommets, 0);
vector<bool> estDans(nbSommets, true);
vector<vector<int>> fils(nbSommets);
vector<vector<int>> parents(nbSommets);
for(int iArc = 0;iArc < (int)debs.size();iArc++) {
fils[debs[iArc]].push_back(fins[iArc]);
parents[fins[iArc]].push_back(debs[iArc]);
}
int nbRecharges = 0;
vector<int> file(2 * nbSommets, 0);
int deb = 0, fin = nbSommets;
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
file[iSommet] = iSommet;
if(estRecharge[iSommet])
nbRecharges += 1;
}
while(deb != fin) {
int sommet = file[deb++];
deb %= 2 * nbSommets;
if(scores[sommet] != nbRecharges + 1) {
estDans[sommet] = false;
}
else {
continue;
}
int oldScore = scores[sommet];
int score;
if(estMax[sommet]) {
score = 0;
for(int fil : fils[sommet]) {
score = max(score, scores[fil]);
}
}
else {
score = nbRecharges + 2;
int nb = 0;
for(int fil : fils[sommet]) {
if(scores[fil] < score) {
score = scores[fil];
nb = 0;
}
if(score == scores[fil]) {
nb++;
}
}
nbMins[sommet] = nb;
}
aggregs[sommet] = score;
if(estRecharge[sommet]) {
score += 1;
}
if(score > nbRecharges + 1) {
score = nbRecharges + 1;
nbMins[sommet] = 1000ll * 1000 * 1000ll;
}
scores[sommet] = score;
if(score == oldScore) continue;
for(int parent : parents[sommet]) {
if(estDans[parent]) continue;
if(estMax[parent] && score > aggregs[parent]) {
file[fin++] = parent;
fin %= 2 * nbSommets;
estDans[parent] = true;
}
if(!estMax[parent] && oldScore == aggregs[parent]) {
nbMins[parent]--;
if(nbMins[parent] <= 0) {
file[fin++] = parent;
fin %= 2 * nbSommets;
estDans[parent] = true;
}
}
}
}
vector<int> estGagnant;
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
estGagnant.push_back(scores[iSommet] >= nbRecharges + 1);
}
return estGagnant;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
1108 KB |
Output is correct |
2 |
Correct |
170 ms |
1108 KB |
Output is correct |
3 |
Correct |
181 ms |
1100 KB |
Output is correct |
4 |
Correct |
181 ms |
1108 KB |
Output is correct |
5 |
Correct |
186 ms |
1108 KB |
Output is correct |
6 |
Correct |
181 ms |
1084 KB |
Output is correct |
7 |
Correct |
51 ms |
1092 KB |
Output is correct |
8 |
Correct |
266 ms |
1088 KB |
Output is correct |
9 |
Correct |
198 ms |
1068 KB |
Output is correct |
10 |
Correct |
205 ms |
1052 KB |
Output is correct |
11 |
Correct |
175 ms |
1080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
224 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
1460 KB |
Output is correct |
2 |
Correct |
132 ms |
1452 KB |
Output is correct |
3 |
Correct |
171 ms |
1444 KB |
Output is correct |
4 |
Correct |
239 ms |
1408 KB |
Output is correct |
5 |
Correct |
77 ms |
1404 KB |
Output is correct |
6 |
Correct |
10 ms |
1492 KB |
Output is correct |
7 |
Correct |
184 ms |
1396 KB |
Output is correct |
8 |
Correct |
8 ms |
1364 KB |
Output is correct |
9 |
Correct |
6 ms |
1364 KB |
Output is correct |
10 |
Correct |
14 ms |
1364 KB |
Output is correct |
11 |
Correct |
7 ms |
1364 KB |
Output is correct |
12 |
Correct |
7 ms |
1356 KB |
Output is correct |
13 |
Correct |
9 ms |
1380 KB |
Output is correct |
14 |
Correct |
9 ms |
1364 KB |
Output is correct |
15 |
Correct |
11 ms |
1376 KB |
Output is correct |
16 |
Correct |
8 ms |
1364 KB |
Output is correct |
17 |
Correct |
10 ms |
1364 KB |
Output is correct |
18 |
Correct |
120 ms |
1152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2095 ms |
1236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1364 KB |
Output is correct |
2 |
Correct |
9 ms |
1492 KB |
Output is correct |
3 |
Correct |
10 ms |
1484 KB |
Output is correct |
4 |
Correct |
10 ms |
1364 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
5 ms |
1108 KB |
Output is correct |
7 |
Correct |
6 ms |
852 KB |
Output is correct |
8 |
Correct |
5 ms |
852 KB |
Output is correct |
9 |
Correct |
6 ms |
852 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
5 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
1108 KB |
Output is correct |
2 |
Correct |
170 ms |
1108 KB |
Output is correct |
3 |
Correct |
181 ms |
1100 KB |
Output is correct |
4 |
Correct |
181 ms |
1108 KB |
Output is correct |
5 |
Correct |
186 ms |
1108 KB |
Output is correct |
6 |
Correct |
181 ms |
1084 KB |
Output is correct |
7 |
Correct |
51 ms |
1092 KB |
Output is correct |
8 |
Correct |
266 ms |
1088 KB |
Output is correct |
9 |
Correct |
198 ms |
1068 KB |
Output is correct |
10 |
Correct |
205 ms |
1052 KB |
Output is correct |
11 |
Correct |
175 ms |
1080 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
224 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
72 ms |
1460 KB |
Output is correct |
33 |
Correct |
132 ms |
1452 KB |
Output is correct |
34 |
Correct |
171 ms |
1444 KB |
Output is correct |
35 |
Correct |
239 ms |
1408 KB |
Output is correct |
36 |
Correct |
77 ms |
1404 KB |
Output is correct |
37 |
Correct |
10 ms |
1492 KB |
Output is correct |
38 |
Correct |
184 ms |
1396 KB |
Output is correct |
39 |
Correct |
8 ms |
1364 KB |
Output is correct |
40 |
Correct |
6 ms |
1364 KB |
Output is correct |
41 |
Correct |
14 ms |
1364 KB |
Output is correct |
42 |
Correct |
7 ms |
1364 KB |
Output is correct |
43 |
Correct |
7 ms |
1356 KB |
Output is correct |
44 |
Correct |
9 ms |
1380 KB |
Output is correct |
45 |
Correct |
9 ms |
1364 KB |
Output is correct |
46 |
Correct |
11 ms |
1376 KB |
Output is correct |
47 |
Correct |
8 ms |
1364 KB |
Output is correct |
48 |
Correct |
10 ms |
1364 KB |
Output is correct |
49 |
Correct |
120 ms |
1152 KB |
Output is correct |
50 |
Execution timed out |
2095 ms |
1236 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |