#include<bits/stdc++.h>
/*#include <cstdio>
#include <vector>
#include <cassert>*/
#include "train.h"
using namespace std;
const int MAX_GARE=5000;
int nbGare,nbChemin,nbBon,deb;
vector<int> adja[MAX_GARE];
deque<int> aTraiter;
int dv[MAX_GARE];
int charge[MAX_GARE];
void DFS(int pos) {
if (dv[pos]!=deb+1) {
dv[pos]=deb+1;
for (int ivois=0;ivois<adja[pos].size();ivois++) {
DFS(adja[pos][ivois]);
}
}
else if (pos==deb) {
charge[deb]=1;
}
}
vector<int> who_wins(vector<int> posses, vector<int> recharge, vector<int> dep, vector<int> arriv) {
vector<int> rep;
rep.clear();
nbGare=posses.size();
for (int i=0;i<nbGare;i++) {
rep.push_back(0);
charge[i]=recharge[i];
}
nbChemin=dep.size();
for (int i=0;i<nbChemin;i++) {
adja[dep[i]].push_back(arriv[i]);
}
for (int i=0;i<nbGare;i++) {
if (charge[i]==1) {
charge[i]=0;
deb=i;
DFS(deb);
}
}
for (int loop=0;loop<nbGare;loop++) {
for (int i=0;i<nbGare;i++) {
nbBon=0;
for (int ivois=0;ivois<adja[i].size();ivois++) {
if (charge[adja[i][ivois]]==1) {
nbBon++;
}
}
if (charge[i]==1) {
rep[i]=1;
}
else if (posses[i]==1 and nbBon>=1) {
rep[i]=1;
charge[i]=1;
}
else if (nbBon==adja[i].size()) {
rep[i]=1;
charge[i]=1;
}
}
}
return rep;
}
/*
int main() {
int n, m;
assert(2 == scanf("%d %d", &n, &m));
vector<int> a(n), r(n), u(m), v(m);
for(int i = 0; i < n; i++)
assert(1 == scanf("%d", &a[i]));
for(int i = 0; i < n; i++)
assert(1 == scanf("%d", &r[i]));
for(int i = 0; i < m; i++)
assert(2 == scanf("%d %d", &u[i], &v[i]));
vector<int> res = who_wins(a, r, u, v);
for(int i = 0; i < (int)res.size(); i++)
printf(i ? " %d" : "%d", res[i]);
printf("\n");
return 0;
}*/
Compilation message
train.cpp: In function 'void DFS(int)':
train.cpp:18:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for (int ivois=0;ivois<adja[pos].size();ivois++) {
| ~~~~~^~~~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:49:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int ivois=0;ivois<adja[i].size();ivois++) {
| ~~~~~^~~~~~~~~~~~~~~
train.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | else if (nbBon==adja[i].size()) {
| ~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
318 ms |
1032 KB |
3rd lines differ - on the 42nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
412 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
3rd lines differ - on the 3rd token, expected: '0', found: '1' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
302 ms |
1232 KB |
Output is correct |
2 |
Correct |
363 ms |
1352 KB |
Output is correct |
3 |
Correct |
407 ms |
1364 KB |
Output is correct |
4 |
Correct |
1065 ms |
1356 KB |
Output is correct |
5 |
Correct |
892 ms |
1336 KB |
Output is correct |
6 |
Correct |
518 ms |
1284 KB |
Output is correct |
7 |
Correct |
636 ms |
1256 KB |
Output is correct |
8 |
Correct |
784 ms |
1260 KB |
Output is correct |
9 |
Correct |
391 ms |
1236 KB |
Output is correct |
10 |
Correct |
725 ms |
1228 KB |
Output is correct |
11 |
Correct |
762 ms |
1196 KB |
Output is correct |
12 |
Correct |
406 ms |
1168 KB |
Output is correct |
13 |
Correct |
384 ms |
1360 KB |
Output is correct |
14 |
Correct |
407 ms |
1364 KB |
Output is correct |
15 |
Correct |
442 ms |
1368 KB |
Output is correct |
16 |
Correct |
414 ms |
1364 KB |
Output is correct |
17 |
Correct |
389 ms |
1356 KB |
Output is correct |
18 |
Correct |
359 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1244 ms |
1128 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
864 ms |
1252 KB |
Output is correct |
2 |
Correct |
367 ms |
1356 KB |
Output is correct |
3 |
Correct |
689 ms |
1356 KB |
Output is correct |
4 |
Correct |
366 ms |
1228 KB |
Output is correct |
5 |
Correct |
1 ms |
416 KB |
Output is correct |
6 |
Correct |
249 ms |
880 KB |
Output is correct |
7 |
Correct |
40 ms |
972 KB |
Output is correct |
8 |
Incorrect |
55 ms |
1064 KB |
3rd lines differ - on the 5th token, expected: '0', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
318 ms |
1032 KB |
3rd lines differ - on the 42nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |