#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;
const int MOD = 1e9 + 7;
int n, m ;
vi adj[nax], rev_adj[nax];
int siz[nax];
set<int> cur;
int cnt[nax];
int A[nax];
void rec(int x)
{
if(cur.count(x) != 0)
return ;
cur.insert(x);
for(auto e: rev_adj[x])
{
cnt[e]++;
if(cnt[e] == siz[e])
rec(e);
else if(A[e])
rec(e);
}
}
vi who_wins(vi a, vi r, vi u, vi v)
{
n = a.size();
m = u.size();
for(int i= 0 ; i < n; i++)
A[i] = a[i];
for(int i= 0; i < m; i ++)
{
adj[u[i]].pb(v[i]);
rev_adj[v[i]].pb(u[i]);
}
for(int i = 0 ; i < n; i ++ )
siz[i] = (int)(adj[i].size());
vi ans(n, 0);
vi chrg;
for(int i= 0 ; i < n;i ++)
if(r[i])
chrg.pb(i);
int sz = chrg.size();
if(sz == 0)
return ans;
for(int mask = 1; mask < (1 << sz); mask ++)
{
vi org;
for(int i= 0; i < sz; i ++)
if((1 << i) & mask)
org.pb(chrg[i]);
cur.clear();
for(int i= 0 ; i < n;i ++)
cnt[i] = 0 ;
for(auto e: org)
{
rec(e);
}
bool flag= true;
for(auto e: org)
{
if(a[e])
{
if(cnt[e] == 0)
flag = false;
}
if(!a[e] && (cnt[e] != siz[e]))
flag = false;
}
if(flag)
{
for(auto e: cur)
ans[e] = 1;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1073 ms |
1196 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
544 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
552 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
544 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2095 ms |
2004 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2052 ms |
1392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1492 KB |
Output is correct |
2 |
Correct |
11 ms |
1764 KB |
Output is correct |
3 |
Correct |
9 ms |
1620 KB |
Output is correct |
4 |
Correct |
10 ms |
1636 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
4 ms |
980 KB |
Output is correct |
7 |
Correct |
5 ms |
1108 KB |
Output is correct |
8 |
Correct |
5 ms |
1168 KB |
Output is correct |
9 |
Correct |
8 ms |
1108 KB |
Output is correct |
10 |
Correct |
3 ms |
724 KB |
Output is correct |
11 |
Correct |
8 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1073 ms |
1196 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |