#include "train.h"
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::vector;
using ll = int;
using vi = vector<ll>;
using vii = vector<vi>;
using std::string;
using pii = std::pair<ll,ll>;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define all(a) a.begin(), a.end()
#define mp std::make_pair
#define pb emplace_back
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
ll N = a.size();
vii edge(N);
rep(i,0,u.size()) edge[u[i]].pb(v[i]);
vi dp = r;
REP(t,0,N+100){
rep(i,0,N){
if(a[i] == 1){
int val = 0;
for(auto next: edge[i]){
val |= dp[next];
}
dp[i] |= val;
}
else{
int val = 1;
for(auto next: edge[i]){
val &= dp[next];
}
dp[i] |= val;
}
}
}
vi dp2 = dp;
rep(i,0,N) dp2[i] = 1-dp2[i];
REP(t,0,N+100){
rep(i,0,N){
if(a[i] == 0){
for(auto next: edge[i]){
dp2[i] |= dp2[next];
}
}
else{
int val = 1;
for(auto next: edge[i]){
val &= dp2[next];
}
dp2[i] |= val;
}
}
}
rep(i,0,N) dp2[i] = 1-dp2[i];
return dp2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
208 ms |
752 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 4th token, expected: '0', found: '1' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
324 ms |
1048 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
378 ms |
1024 KB |
Output is correct |
2 |
Correct |
420 ms |
968 KB |
Output is correct |
3 |
Correct |
471 ms |
1024 KB |
Output is correct |
4 |
Correct |
462 ms |
1136 KB |
Output is correct |
5 |
Correct |
454 ms |
932 KB |
Output is correct |
6 |
Correct |
480 ms |
1128 KB |
Output is correct |
7 |
Correct |
461 ms |
1012 KB |
Output is correct |
8 |
Correct |
461 ms |
1000 KB |
Output is correct |
9 |
Correct |
413 ms |
972 KB |
Output is correct |
10 |
Correct |
477 ms |
980 KB |
Output is correct |
11 |
Correct |
457 ms |
1036 KB |
Output is correct |
12 |
Correct |
441 ms |
1100 KB |
Output is correct |
13 |
Correct |
476 ms |
1016 KB |
Output is correct |
14 |
Correct |
428 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
509 ms |
1044 KB |
Output is correct |
2 |
Correct |
520 ms |
1028 KB |
Output is correct |
3 |
Correct |
588 ms |
1040 KB |
Output is correct |
4 |
Correct |
509 ms |
976 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
223 ms |
764 KB |
Output is correct |
7 |
Correct |
30 ms |
724 KB |
Output is correct |
8 |
Incorrect |
24 ms |
796 KB |
3rd lines differ - on the 5th token, expected: '0', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
208 ms |
752 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |