# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
607458 |
2022-07-26T17:48:31 Z |
Arturgo |
Toy Train (IOI17_train) |
C++17 |
|
266 ms |
1460 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;
deque<int> file;
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
file.push_back(iSommet);
if(estRecharge[iSommet])
nbRecharges += 1;
}
while(!file.empty()) {
int sommet = file.back();
file.pop_back();
estDans[sommet] = false;
int oldScore = scores[sommet];
int score;
if(estMax[sommet]) {
score = 0;
for(int fil : fils[sommet]) {
score = max(score, scores[fil]);
}
}
else {
score = nbRecharges + 1;
int nb = 0;
for(int fil : fils[sommet]) {
if(score < scores[fil]) {
score = scores[fil];
nb = 0;
}
if(score == scores[fil]) {
nb++;
}
}
nbMins[sommet] = nb;
}
aggregs[sommet] = score;
if(estRecharge[sommet]) {
score += 1;
}
score = min(score, nbRecharges + 1);
scores[sommet] = score;
if(score == oldScore) continue;
for(int parent : parents[sommet]) {
if(estDans[parent]) continue;
if(estMax[parent] && score > aggregs[parent]) {
file.push_front(parent);
estDans[parent] = true;
}
if(!estMax[parent] && oldScore == aggregs[parent]) {
nbMins[parent]--;
if(nbMins[parent] == 0) {
file.push_front(parent);
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 |
Incorrect |
4 ms |
1108 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
1460 KB |
Output is correct |
2 |
Correct |
124 ms |
1432 KB |
Output is correct |
3 |
Correct |
157 ms |
1432 KB |
Output is correct |
4 |
Correct |
266 ms |
1388 KB |
Output is correct |
5 |
Correct |
76 ms |
1388 KB |
Output is correct |
6 |
Correct |
11 ms |
1364 KB |
Output is correct |
7 |
Correct |
173 ms |
1384 KB |
Output is correct |
8 |
Correct |
10 ms |
1372 KB |
Output is correct |
9 |
Correct |
7 ms |
1364 KB |
Output is correct |
10 |
Correct |
13 ms |
1372 KB |
Output is correct |
11 |
Correct |
7 ms |
1364 KB |
Output is correct |
12 |
Correct |
8 ms |
1364 KB |
Output is correct |
13 |
Correct |
8 ms |
1356 KB |
Output is correct |
14 |
Correct |
8 ms |
1364 KB |
Output is correct |
15 |
Correct |
8 ms |
1364 KB |
Output is correct |
16 |
Correct |
8 ms |
1364 KB |
Output is correct |
17 |
Correct |
8 ms |
1364 KB |
Output is correct |
18 |
Correct |
112 ms |
1140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1236 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1364 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1108 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |