이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <queue>
#include <utility>
using namespace std;
bool have[300005];
bool vis[300005];
int con[300005];
vector < int > ans;
vector < pair < int , int > > Next[300005];
vector < int > all[300005];
queue < int > BFS;
vector < int > find_reachable(vector < int > r, vector < int > u, vector < int > v, vector < int > c)
{
int N=r.size(),M=u.size(),i,j,now,small=2e9;
for(i=0;i<M;i++)
{
Next[u[i]].push_back(make_pair(v[i],c[i]));
Next[v[i]].push_back(make_pair(u[i],c[i]));
}
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
all[j].clear();
vis[j]=0;
have[j]=0;
}
BFS.push(i);
while(!BFS.empty())
{
now=BFS.front();
BFS.pop();
if(vis[now]) continue;
vis[now]=1;
con[i]++;
if(!have[r[now]])
{
have[r[now]]=1;
for(auto j:all[r[now]]) BFS.push(j);
all[r[now]].clear();
}
for(auto j:Next[now])
{
if(have[j.second]) BFS.push(j.first);
else all[j.second].push_back(j.first);
}
}
}
for(i=0;i<N;i++) small=min(small,con[i]);
for(i=0;i<N;i++) ans.push_back(con[i]==small);
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... |