이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "keys.h"
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
int n = r.size();int m = u.size();
vector<vector<pii>> adj(n);
for (int i = 0; i < m; i++)
{
adj[u[i]].push_back({v[i], c[i]});
adj[v[i]].push_back({u[i], c[i]});
}
vector<int> reach(n, 0);
for (int i = 0; i < n; i++)
{
vector<bool> mkeys(n, 0);
vector<bool> vis(n, 0);
int vcount = 0;
vector<vector<int>> unlockables(n);
queue<int> q;
q.push(i);
while (!q.empty())
{
int cn = q.front();q.pop();
if (vis[cn]) continue;
vis[cn] = 1;
vcount++;
mkeys[r[cn]] = 1;
for (int j : unlockables[r[cn]]) {
q.push(j);
}
unlockables[r[cn]].clear();
for (auto nn : adj[cn]) {
if (mkeys[nn.second]) {
q.push(nn.first);
}
else {
unlockables[nn.second].push_back(nn.first);
}
}
}
reach[i] = vcount;
}
int mr = *min_element(all(reach));
vector<int> ans(n);
for (int i = 0; i < n; i++)
{
ans[i] = reach[i] == mr;
}
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... |