#include "train.h"
#include <vector>
#include <algorithm>
using namespace std;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size(), m = u.size();
vector<vector<int> > g(n);
for(int i = 0; i < m; ++i) {
g[u[i]].push_back(v[i]);
}
vector<int> dp(n, n);
for(int i = 0; i < n * n; ++i) {
vector<int> ndp(n);
for(int j = 0; j < n; ++j) {
if(a[j] == 1) {
ndp[j] = 0;
for(int k : g[j]) {
ndp[j] = min(ndp[j], dp[k]);
}
}
else {
ndp[j] = n;
for(int k : g[j]) {
ndp[j] = min(ndp[j], dp[k] > 0 ? dp[k] - 1 : 0);
}
}
if(r[j] == 1 && ndp[j] > 0) {
ndp[j] = n;
}
}
dp = ndp;
}
vector<int> ans(n);
for(int i = 0; i < n; ++i) {
ans[i] = (dp[i] > 0 ? 1 : 0);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2035 ms |
896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 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 |
Execution timed out |
2004 ms |
1152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2037 ms |
1024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2028 ms |
1152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2035 ms |
896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |