# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
592790 |
2022-07-09T15:43:23 Z |
Richem |
Toy Train (IOI17_train) |
C++14 |
|
42 ms |
25420 KB |
#include <iostream>
#include <vector>
using namespace std;
const int MAX_SOMMET = 5042;
int gagnant[MAX_SOMMET] = {0};
int nbSommet, nbArete;
bool adj[MAX_SOMMET][MAX_SOMMET] = {0};
bool qui[MAX_SOMMET] = {0};
bool recharge[MAX_SOMMET] = {0};
int dfs(int sommet) {
if(gagnant[sommet] != -1)
return gagnant[sommet];
gagnant[sommet] = 0;
for(int voisin = 0; voisin < MAX_SOMMET; voisin++) {
if(adj[sommet][voisin] == 0)
continue;
dfs(voisin);
gagnant[sommet] = gagnant[voisin];
}
return gagnant[sommet];
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
nbSommet = a.size();
nbArete = u.size();
for(int i = 0; i < nbSommet; i++) {
gagnant[i] = -1;
qui[i] = a[i];
recharge[i] = r[i];
}
for(int id = 0; id < nbArete; id++) {
if(u[id] == v[id]) {
if(a[u[id]] == 0) {
gagnant[u[id]] = 0;
}
if(a[u[id]] == 1 && r[u[id]] == 1) {
gagnant[u[id]] = 1;
}
}
else {
adj[u[id]][v[id]] = 1;
}
}
for(int sommet = 0; sommet < nbSommet; sommet++)
dfs(sommet);
vector<int> rep;
for(int i = 0; i < nbSommet; i++)
rep.push_back(gagnant[i]);
return rep;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
20564 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
20228 KB |
Output is correct |
2 |
Correct |
32 ms |
21292 KB |
Output is correct |
3 |
Correct |
37 ms |
22332 KB |
Output is correct |
4 |
Incorrect |
33 ms |
25420 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
24112 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
24916 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
20564 KB |
3rd lines differ - on the 26th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |