#include <bits/stdc++.h>
#include "train.h"
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
#define pb push_back
#define popb pop_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
const int nax = 5004;
int C[nax];
vi adj[nax];
vi rev_adj[nax];
int A[nax];
int n, m;
int dp[nax][nax];
int f(int x, int rem)
{
if(dp[x][rem] != -1)
return dp[x][rem];
if(rem == 0)
return dp[x][rem] = 1 - A[x];
int rep = 0;
for(auto e: adj[x])
{
if(e == x)
{
if(C[x])
rep = rep | A[x];
}
else
rep = rep | f(e, rem - 1);
}
return dp[x][rem] = rep;
}
vi who_wins(vi a, vi r, vi u, vi v)
{
memset(dp, -1,sizeof(dp));
n = a.size();
m = u.size();
for(int i = 0 ; i < n; i++)
{
A[i] = a[i];
C[i] = r[i];
}
for(int i= 0; i < m; i++)
{
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
vi ans;
for(int i = 0; i < n;i ++)
ans.pb(f(i, n)^(A[i] == 0));
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
982 ms |
99404 KB |
3rd lines differ - on the 3rd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
98488 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1308 ms |
99672 KB |
Output is correct |
2 |
Correct |
1471 ms |
99888 KB |
Output is correct |
3 |
Correct |
1446 ms |
99872 KB |
Output is correct |
4 |
Execution timed out |
2086 ms |
99904 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2092 ms |
99492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2102 ms |
99608 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
982 ms |
99404 KB |
3rd lines differ - on the 3rd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |