# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
613835 |
2022-07-30T11:56:39 Z |
Richem |
Toy Train (IOI17_train) |
C++14 |
|
8 ms |
1492 KB |
#include <iostream>
#include <vector>
using namespace std;
const int MAX_SOMMET = 5042;
bool gagnant[MAX_SOMMET] = {0};
int qui[MAX_SOMMET];
bool recharge[MAX_SOMMET];
int nbSommet, nbArete;
vector<int> adj[MAX_SOMMET];
int nbSortant[MAX_SOMMET] = {0};
bool acces[MAX_SOMMET] = {0};
int premier = 1;
void dfs(int sommet, int type) {
if((type == 1 && acces[sommet]) || (type == 2 && gagnant[sommet]))
return;
if(!premier && type == 1)
acces[sommet] = 1;
if(type == 2)
gagnant[sommet] = 1;
premier = 0;
for(auto voisin : adj[sommet]) {
if(qui[voisin] == 1)
dfs(voisin, type);
else {
nbSortant[voisin]--;
if(nbSortant[voisin] == 0)
dfs(voisin, type);
}
}
}
void resetSortant() {
for(int sommet = 0; sommet < nbSommet; sommet++) {
nbSortant[sommet] = 0;
acces[sommet] = 0;
}
for(int sommet = 0; sommet < nbSommet; sommet++) {
for(auto voisin : adj[sommet]) {
nbSortant[voisin]++;
}
}
}
vector<int> rep;
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] = 0;
qui[i] = a[i];
recharge[i] = r[i];
}
for(int id = 0; id < nbArete; id++) {
adj[v[id]].push_back(u[id]);
}
int nbPerdu = 0;
do {
nbPerdu = 0;
resetSortant();
for(int sommet = 0; sommet < nbSommet; sommet++) {
if(recharge[sommet])
dfs(sommet, 1);
}
for(int sommet = 0; sommet < nbSommet; sommet++) {
if(recharge[sommet] && !acces[sommet]) {
nbPerdu++;
recharge[sommet] = 0;
}
}
} while(nbPerdu > 0);
resetSortant();
for(int sommet = 0; sommet < nbSommet; sommet++) {
if(recharge[sommet])
dfs(sommet, 2);
}
for(int sommet = 0; sommet < nbSommet; sommet++) {
rep.push_back(gagnant[sommet]);
}
return rep;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
952 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 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
440 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1492 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 |
6 ms |
1124 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 |
1344 KB |
Output is correct |
2 |
Correct |
7 ms |
1364 KB |
Output is correct |
3 |
Correct |
8 ms |
1332 KB |
Output is correct |
4 |
Correct |
6 ms |
1236 KB |
Output is correct |
5 |
Correct |
1 ms |
436 KB |
Output is correct |
6 |
Correct |
3 ms |
852 KB |
Output is correct |
7 |
Correct |
4 ms |
964 KB |
Output is correct |
8 |
Correct |
5 ms |
988 KB |
Output is correct |
9 |
Correct |
6 ms |
1036 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
5 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
952 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |