#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+10){
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+10){
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 |
203 ms |
884 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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 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 |
331 ms |
1064 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 |
366 ms |
916 KB |
Output is correct |
2 |
Correct |
405 ms |
1124 KB |
Output is correct |
3 |
Correct |
453 ms |
1256 KB |
Output is correct |
4 |
Correct |
472 ms |
1244 KB |
Output is correct |
5 |
Correct |
449 ms |
1200 KB |
Output is correct |
6 |
Correct |
449 ms |
1220 KB |
Output is correct |
7 |
Correct |
452 ms |
1216 KB |
Output is correct |
8 |
Correct |
451 ms |
1172 KB |
Output is correct |
9 |
Correct |
436 ms |
1136 KB |
Output is correct |
10 |
Correct |
441 ms |
1356 KB |
Output is correct |
11 |
Correct |
471 ms |
1252 KB |
Output is correct |
12 |
Correct |
440 ms |
1252 KB |
Output is correct |
13 |
Correct |
480 ms |
1244 KB |
Output is correct |
14 |
Correct |
513 ms |
1176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
520 ms |
1020 KB |
Output is correct |
2 |
Correct |
508 ms |
1236 KB |
Output is correct |
3 |
Correct |
582 ms |
1356 KB |
Output is correct |
4 |
Correct |
515 ms |
1108 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
193 ms |
844 KB |
Output is correct |
7 |
Correct |
20 ms |
876 KB |
Output is correct |
8 |
Incorrect |
22 ms |
852 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 |
203 ms |
884 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |