// In the name of Allah
#include <bits/stdc++.h>
#include "train.h"
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> cld;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define X real()
#define Y imag()
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0)
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 2e5 + 7;
int n, m;
vector<int> adj[maxn], adjr[maxn];
pii A[maxn]; int D[maxn];
int mark[maxn]; queue<int> qu;
vector<int> res;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> ux, vector<int> vx) {
n = len(a); m = len(ux);
for (int i = 0; i < n; i++) A[i] = Mp(a[i], r[i]);
for (int i = 0; i < m; i++) {
int u = ux[i], v = vx[i];
adj[u].pb(v); adjr[v].pb(u);
}
fill(mark, mark + n, 0);
for (int i = 0; i < n; i++) {
D[i] = len(adj[i]);
if (A[i].S == 1) {
qu.push(i); mark[i] = 1;
}
}
while (!qu.empty()) {
int v = qu.front(); qu.pop();
for (int u : adjr[v]) {
D[u]--;
if (!mark[u]) {
if (A[u].F == 1) {
qu.push(u); mark[u] = 1;
}
else if (D[u] == 0) {
qu.push(u); mark[u] = 1;
}
}
}
}
for (int i = 0; i < n; i++) {
mark[i] = !mark[i];
D[i] = len(adj[i]);
if (mark[i]) {
qu.push(i);
}
}
while (!qu.empty()) {
int v = qu.front(); qu.pop();
for (int u : adjr[v]) {
D[u]--;
if (!mark[u]) {
if (A[u].F == 0) {
qu.push(u); mark[u] = 1;
}
else if (D[u] == 0) {
qu.push(u); mark[u] = 1;
}
}
}
}
res.resize(n);
for (int i = 0; i < n; i++) res[i] = !mark[i];
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
13404 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 |
2 ms |
12636 KB |
Output is correct |
2 |
Correct |
2 ms |
12636 KB |
Output is correct |
3 |
Correct |
2 ms |
12636 KB |
Output is correct |
4 |
Incorrect |
2 ms |
12636 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 |
6 ms |
13916 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 |
6 ms |
13660 KB |
Output is correct |
2 |
Correct |
6 ms |
13660 KB |
Output is correct |
3 |
Correct |
6 ms |
13804 KB |
Output is correct |
4 |
Correct |
6 ms |
13660 KB |
Output is correct |
5 |
Correct |
7 ms |
13660 KB |
Output is correct |
6 |
Correct |
7 ms |
13692 KB |
Output is correct |
7 |
Correct |
7 ms |
13660 KB |
Output is correct |
8 |
Correct |
7 ms |
13796 KB |
Output is correct |
9 |
Correct |
6 ms |
13660 KB |
Output is correct |
10 |
Correct |
8 ms |
13660 KB |
Output is correct |
11 |
Correct |
8 ms |
13660 KB |
Output is correct |
12 |
Correct |
8 ms |
13660 KB |
Output is correct |
13 |
Correct |
7 ms |
13656 KB |
Output is correct |
14 |
Correct |
6 ms |
13576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
13660 KB |
Output is correct |
2 |
Correct |
7 ms |
13660 KB |
Output is correct |
3 |
Correct |
7 ms |
13660 KB |
Output is correct |
4 |
Correct |
7 ms |
13660 KB |
Output is correct |
5 |
Correct |
2 ms |
12636 KB |
Output is correct |
6 |
Correct |
4 ms |
13404 KB |
Output is correct |
7 |
Correct |
5 ms |
13404 KB |
Output is correct |
8 |
Incorrect |
5 ms |
13404 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 |
4 ms |
13404 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |