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 <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f1 first
#define s2 second
using ii = pair<int, int>;
const int MAX = 2069;
bitset<MAX> vst, key;
vector<ii> adj[MAX];
vector<int> pend[MAX];
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c)
{
int N = (int)r.size(), M = (int)u.size();
for (int i = 0; i < M; ++i)
{
adj[u[i]].pb({v[i], c[i]});
adj[v[i]].pb({u[i], c[i]});
}
vector<int> ans(r.size(), 1);
for (int st = 0; st < N; ++st)
{
vst.reset(); key.reset();
for (int i = 0; i < N; ++i)
pend[i].clear();
queue<int> q;
vst[st] = true;
q.push(st);
while (!q.empty())
{
int node = q.front();
q.pop();
key[r[node]] = true;
for (int to : pend[r[node]]) if (!vst[to])
{
vst[to] = true;
q.push(to);
}
pend[r[node]].clear();
for (auto [to, id] : adj[node]) if (!vst[to])
{
if (key[id])
{
vst[to] = true;
q.push(to);
}
else
{
pend[id].pb(to);
}
}
}
ans[st] = (int)vst.count();
}
int mn = *min_element(ans.begin(), ans.end());
for (int &x : ans)
x = x == mn;
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... |