#include "train.h"
#include <bits/stdc++.h>
#define N 15
using namespace std;
int dp[(1<<N)][N];
bool edge[N][N];
bool special[N];
vector<int> adj[N];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size();
int m = u.size();
for(int i=0;i<m;i++){
edge[u[i]][v[i]] = 1;
adj[u[i]].push_back(v[i]);
}
for(int i = 0;i<n;i++){
if(r[i]){
for(int mask = (1<<n)-1;mask>=0;mask--){
for(int j = 0;j<n;j++){
if(!(mask & (1<<j)))continue;
if(a[j]){
dp[mask][j] = 0;
for(auto u:adj[j]){
if((mask & (1<<u))){
dp[mask][j] |= (u == i);
continue;
}
dp[mask][j] |= dp[mask + (1<<u)][u];
}
}
else{
dp[mask][j] = 1;
for(auto u:adj[j]){
if((mask & (1<<u))){
dp[mask][j] &= (u == i);
continue;
}
dp[mask][j] &= dp[mask + (1<<u)][u];
}
}
//cout << mask << " " << j << " " << dp[mask][j] << endl;
}
}
special[i] = dp[(1<<i)][i];
//cout << i << " " << special[i] << endl;
}
}
vector<int> res(n);
for(int i = 0; i < n; i++){
for(int mask = (1<<n)-1;mask>=0;mask--){
bool x = 0;
for(int c = 0;c<n;c++){
if(mask & (1<<c))
x |= special[c];
}
for(int j = 0;j<n;j++){
if(!(mask & (1<<j)))continue;
dp[mask][j] = 0;
if(a[j]){
for(auto u:adj[j]){
if((mask & (1<<u))){
continue;
}
dp[mask][j] |= dp[mask + (1<<u)][u];
}
}
else{
dp[mask][j] = 1;
for(auto u:adj[j]){
if((mask & (1<<u))){
dp[mask][j] = 0;
continue;
}
dp[mask][j] &= dp[mask + (1<<u)][u];
}
}
dp[mask][j] |= x;
}
}
res[i] = dp[(1<<i)][i];
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
980 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
126 ms |
2204 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 |
Runtime error |
6 ms |
1620 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
1596 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
1728 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
980 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |