This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define SZ(a) ((int)a.size())
vector<pii> G[300005];
int vis[300005];
vector<int> stk;
void dfs(int u) {
stk.pb(u);
vis[u] = 1;
for (pii i : G[u])
if (!vis[i.X])
dfs(i.X);
}
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
int n = SZ(r), m = SZ(u);
vector<int> ans(n, 0);
vector<int> arr(n, 0);
for (int i = 0; i < m; ++i) {
G[u[i]].pb(pii(v[i], c[i]));
G[v[i]].pb(pii(u[i], c[i]));
}
for (int i = 0; i < n; ++i)
if (!vis[i]) {
stk.clear();
dfs(i);
for (int j : stk)
if (r[j] == 0)
arr[j] = SZ(stk);
else
arr[j] = 1;
}
int mi = *min_element(ALL(arr));
for (int i = 0; i < n; ++i)
if (arr[i] == mi)
ans[i] = 1;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |