이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "keys.h"
using namespace std;
vector<pair<int,int> >g[2048];
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
vector<int> ans(r.size(), 1);
int n=r.size();
int m=u.size();
for(int i=0;i<m;i++)
{
g[u[i]].push_back({v[i],c[i]});
g[v[i]].push_back({u[i],c[i]});
}
set<int>found_keys;
bool vis[2048];
queue<int>edges[2048];
int minans=n;
for(int i=0;i<n;i++)
{
found_keys.clear();
queue<int>q;
memset(vis,0,sizeof(vis));
vis[i]=1;
int cnt=0;
q.push(i);
while(!q.empty())
{
int f=q.front();
q.pop();cnt++;
if(found_keys.find(r[f])==found_keys.end())
{
while(!edges[r[f]].empty())
{
int w=edges[r[f]].front();
edges[r[f]].pop();
if(vis[w])continue;
q.push(w);vis[w]=1;
}
}
found_keys.insert(r[f]);
for(auto xd:g[f])
{
if(vis[xd.first])continue;
if(found_keys.find(xd.second)!=found_keys.end())
{
vis[xd.first]=1;
q.push(xd.first);
}
else edges[xd.second].push(xd.first);
}
}
for(int j=0;j<2048;j++)
{
while(!edges[j].empty())edges[j].pop();
}
ans[i]=cnt;
minans=min(minans,ans[i]);
}
for(int i=0;i<n;i++)
{
if(ans[i]==minans)ans[i]=1;
else ans[i]=0;
}
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... |