This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "train.h"
using namespace std;
vector<int> adj[5005], tran[5005];
bool reach[5005][5005], reachtran[5005][5005];
bool vis[5005];
int st;
void dfs(int x, vector<int> *vec, bool trans) {
if(vis[x]) return;
vis[x] = 1;
if(trans) reachtran[st][x] = 1;
else reach[st][x] = 1;
for(int e:vec[x])
dfs(e, vec, trans);
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
std::vector<int> res(a.size());
for(int i=0;i<u.size();i++)
adj[u[i]].push_back(v[i]),
tran[v[i]].push_back(u[i]);
if(a[0] == 1) { // arezou (sub 3), find cyc with charging station
for(st=0;st<a.size();st++) {
memset(vis, 0,sizeof vis); dfs(st, adj, 0);
memset(vis, 0,sizeof vis); dfs(st, tran, 1);
}
for(int i=0;i<a.size();i++) {
if(r[i]) {
bool yas = 0;
for(int k=0;k<a.size();k++) {
if(i != k && reach[i][k] && reachtran[k][i]) {
yas = 1;
break;
}
}
res[i] = yas;
} else {
bool yas = 0;
for(int k=0;k<a.size();k++) {
if(i != k && reach[i][k] && reachtran[k][i] && r[k]) {
yas = 1;
break;
}
}
res[i] = yas;
}
}
} else { // borzou (sub 4), find cyc with NO charging station
}
return res;
}
Compilation message (stderr)
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int i=0;i<u.size();i++)
| ~^~~~~~~~~
train.cpp:26:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(st=0;st<a.size();st++) {
| ~~^~~~~~~~~
train.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i=0;i<a.size();i++) {
| ~^~~~~~~~~
train.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int k=0;k<a.size();k++) {
| ~^~~~~~~~~
train.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int k=0;k<a.size();k++) {
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |