#include "train.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define sz(x) (ll)x.size()
#define endl "\n"
#define pb push_back
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
vector <vi> adj, radj;
vi vis;
void dfs(ll u){
vis[u] = 1;
for (ll i =0; i<sz(radj[u]); i++){
ll c = radj[u][i];
if (!vis[c]){
dfs(c);
}
}
}
bool dfs_validation(ll u, ll t){
vis[u] = 1;
for (ll i =0; i<sz(adj[u]); i++){
ll c = adj[u][i];
if (!vis[c]){
if (dfs_validation(c, t)) return true;
}
else if (c == t){
return true;
}
}
return false;
}
vi who_wins(vi a, vi r, vi u, vi v) {
ll n = sz(a), m = sz(u);
adj.assign(n,vi());
radj.assign(n, vi());
for(ll i =0; i<m; i++){
// dbg3(i, u[i], v[i]);
adj[u[i]].pb(v[i]);
radj[v[i]].pb(u[i]);
}
for (ll i = 0; i<n; i++){
if (r[i]){
vis.assign(n,0);
r[i] = dfs_validation(i,i);
}
}
vis.assign(n,0);
for (ll i =0; i<n; i++){
if (!vis[i] && r[i]){
dfs(i);
}
}
return vis;
}
/*
7 9
1 1 1 1 1 1 1
0 1 0 0 0 1 1
0 2
0 1
2 3
1 4
4 5
5 3
3 4
3 6
6 6
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
1372 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 |
Incorrect |
1 ms |
348 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1624 KB |
Output is correct |
2 |
Correct |
19 ms |
1808 KB |
Output is correct |
3 |
Correct |
36 ms |
1824 KB |
Output is correct |
4 |
Correct |
104 ms |
1780 KB |
Output is correct |
5 |
Correct |
18 ms |
1624 KB |
Output is correct |
6 |
Correct |
49 ms |
1628 KB |
Output is correct |
7 |
Correct |
124 ms |
1684 KB |
Output is correct |
8 |
Correct |
5 ms |
1628 KB |
Output is correct |
9 |
Correct |
5 ms |
1628 KB |
Output is correct |
10 |
Correct |
6 ms |
1652 KB |
Output is correct |
11 |
Correct |
5 ms |
1628 KB |
Output is correct |
12 |
Correct |
4 ms |
1472 KB |
Output is correct |
13 |
Correct |
5 ms |
1624 KB |
Output is correct |
14 |
Correct |
5 ms |
1628 KB |
Output is correct |
15 |
Correct |
5 ms |
1628 KB |
Output is correct |
16 |
Correct |
5 ms |
1604 KB |
Output is correct |
17 |
Correct |
5 ms |
1628 KB |
Output is correct |
18 |
Correct |
109 ms |
1436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
308 ms |
1552 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
1628 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
1372 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |