#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define size(x) (int)((x).size())
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
int n = size(a);
vi rg [n];
for (int i = 0; i < size(u); i++) {
rg[v[i]].push_back(u[i]);
}
int dp [n];
for (int i = 0; i < n; i++) dp[i] = 0;
int sc = 0;
for (int i : r) if (i) sc++;
for (int _ = 0; _ < sc+3; _++) {
for (int i = 0; i < n; i++) {
vi to;
for (int j : rg[i]) {
to.push_back(dp[j]);
}
if (to.empty()) continue;
int use = to[0];
if (a[i] == 0) {
for (int j : to) {
use = min(use, j);
}
}
else {
for (int j : to) {
use = max(use, j);
}
}
if (r[i]) {
use++;
}
dp[i] = max(dp[i], use);
}
}
vi win;
for (int i = 0; i < n; i++) {
win.push_back((dp[i] >= sc+1));
}
return win;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
536 ms |
748 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
1040 KB |
Output is correct |
2 |
Correct |
260 ms |
1032 KB |
Output is correct |
3 |
Correct |
378 ms |
1028 KB |
Output is correct |
4 |
Incorrect |
555 ms |
1040 KB |
3rd lines differ - on the 13th token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1716 ms |
888 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
980 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
536 ms |
748 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |