This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author : pham van sam
* created : 15 June 2023 (Thursday)
**/
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#define MASK(x) (1LL << (x))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0, _n = n; i < _n; ++i)
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define FORE(it, s) for (__typeof(s.begin()) it = (s).begin(); it != (s).end(); ++it)
template <typename U, typename V> bool maximize(U &A, const V &B) { return (A < B) ? (A = B, true) : false; }
template <typename U, typename V> bool minimize(U &A, const V &B) { return (A > B) ? (A = B, true) : false; }
vector <int> find_reachable (vector <int> type_keys, vector <int> u, vector <int> v, vector <int> c) {
int N = (int) type_keys.size();
int M = (int) u.size();
vector <int> dd(N), p(N), ans(N);
vector <vector <int>> adj(N);
REP(i, M) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
int run = 0;
function <void(int)> dfs = [&] (int u) {
if(dd[u]) return ;
dd[u] = 1;
run++;
for (auto v : adj[u]) dfs(v);
};
REP(u, N) if(!type_keys[u]) {
fill(ALL(dd), 0);
run = 0;
dfs(u);
p[u] = run;
}
int cur = *min_element(ALL(p));
REP(i, N) ans[i] = (cur == p[i]);
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... |