# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
607541 |
2022-07-26T19:50:22 Z |
Arturgo |
Toy Train (IOI17_train) |
C++14 |
|
1178 ms |
1364 KB |
#include "train.h"
#include <deque>
#include <vector>
using namespace std;
int nbSommets;
vector<int> nouvDegs;
vector<bool> nouvGagnants;
vector<int> estMax;
vector<int> parents[6000];
void explore(int sommet) {
for(int parent : parents[sommet]) {
if(nouvGagnants[parent]) continue;
if(estMax[parent]) {
nouvGagnants[parent] = true;
explore(parent);
}
else {
nouvDegs[parent]--;
if(nouvDegs[parent] == 0) {
nouvGagnants[parent] = true;
explore(parent);
}
}
}
}
vector<int> who_wins(vector<int> _estMax, vector<int> estRecharge,
vector<int> debs, vector<int> fins) {
estMax = _estMax;
nbSommets = estMax.size();
vector<int> degs(nbSommets, 0);
for(int iArc = 0;iArc < (int)debs.size();iArc++) {
parents[fins[iArc]].push_back(debs[iArc]);
degs[debs[iArc]]++;
}
int nbRecharges = 0;
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
if(estRecharge[iSommet])
nbRecharges += 1;
}
vector<bool> gagnants(nbSommets, true);
for(int iFois = 0;iFois <= nbRecharges + 3;iFois++) {
nouvDegs = degs;
nouvGagnants = vector<bool>(nbSommets, false);
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
if(gagnants[iSommet] && estRecharge[iSommet] && !nouvGagnants[iSommet]) {
explore(iSommet);
}
}
gagnants = nouvGagnants;
}
vector<int> estGagnant;
for(int iSommet = 0;iSommet < nbSommets;iSommet++) {
estGagnant.push_back(gagnants[iSommet]);
}
return estGagnant;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
232 ms |
804 KB |
3rd lines differ - on the 22nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 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 |
53 ms |
1316 KB |
Output is correct |
2 |
Correct |
79 ms |
1324 KB |
Output is correct |
3 |
Correct |
116 ms |
1304 KB |
Output is correct |
4 |
Correct |
247 ms |
1220 KB |
Output is correct |
5 |
Correct |
54 ms |
1176 KB |
Output is correct |
6 |
Correct |
12 ms |
1108 KB |
Output is correct |
7 |
Correct |
495 ms |
1072 KB |
Output is correct |
8 |
Correct |
7 ms |
1108 KB |
Output is correct |
9 |
Correct |
7 ms |
1108 KB |
Output is correct |
10 |
Correct |
10 ms |
1116 KB |
Output is correct |
11 |
Correct |
7 ms |
1116 KB |
Output is correct |
12 |
Correct |
7 ms |
980 KB |
Output is correct |
13 |
Correct |
10 ms |
1236 KB |
Output is correct |
14 |
Correct |
9 ms |
1220 KB |
Output is correct |
15 |
Correct |
7 ms |
1236 KB |
Output is correct |
16 |
Correct |
7 ms |
1304 KB |
Output is correct |
17 |
Correct |
8 ms |
1364 KB |
Output is correct |
18 |
Correct |
188 ms |
988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1178 ms |
944 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 |
Correct |
7 ms |
1108 KB |
Output is correct |
2 |
Correct |
8 ms |
1264 KB |
Output is correct |
3 |
Correct |
7 ms |
1108 KB |
Output is correct |
4 |
Correct |
7 ms |
1108 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
4 ms |
764 KB |
Output is correct |
7 |
Correct |
5 ms |
852 KB |
Output is correct |
8 |
Correct |
5 ms |
852 KB |
Output is correct |
9 |
Correct |
8 ms |
828 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Correct |
5 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
232 ms |
804 KB |
3rd lines differ - on the 22nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |