#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] = 1 - qui[sommet];
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 && r[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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
20660 KB |
Output is correct |
2 |
Correct |
25 ms |
20564 KB |
Output is correct |
3 |
Correct |
25 ms |
20564 KB |
Output is correct |
4 |
Correct |
26 ms |
20524 KB |
Output is correct |
5 |
Correct |
30 ms |
20300 KB |
Output is correct |
6 |
Correct |
26 ms |
19472 KB |
Output is correct |
7 |
Correct |
31 ms |
19484 KB |
Output is correct |
8 |
Correct |
28 ms |
19464 KB |
Output is correct |
9 |
Correct |
26 ms |
17084 KB |
Output is correct |
10 |
Correct |
22 ms |
12628 KB |
Output is correct |
11 |
Correct |
16 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
20096 KB |
Output is correct |
2 |
Correct |
33 ms |
21076 KB |
Output is correct |
3 |
Correct |
34 ms |
22040 KB |
Output is correct |
4 |
Incorrect |
36 ms |
25168 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
47 ms |
24036 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
24812 KB |
3rd lines differ - on the 4th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
20660 KB |
Output is correct |
2 |
Correct |
25 ms |
20564 KB |
Output is correct |
3 |
Correct |
25 ms |
20564 KB |
Output is correct |
4 |
Correct |
26 ms |
20524 KB |
Output is correct |
5 |
Correct |
30 ms |
20300 KB |
Output is correct |
6 |
Correct |
26 ms |
19472 KB |
Output is correct |
7 |
Correct |
31 ms |
19484 KB |
Output is correct |
8 |
Correct |
28 ms |
19464 KB |
Output is correct |
9 |
Correct |
26 ms |
17084 KB |
Output is correct |
10 |
Correct |
22 ms |
12628 KB |
Output is correct |
11 |
Correct |
16 ms |
596 KB |
Output is correct |
12 |
Incorrect |
1 ms |
340 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |