이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "keys.h"
#include <cassert>
#include <cstdio>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<pair<ll,ll>>> cad;
std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v1, std::vector<int> c)
{
ll n=r.size();
ll m=u.size();cad.resize(n*2+1);
for(int i=0; i<m; i++){
cad[u[i]].push_back({v1[i],c[i]});
cad[v1[i]].push_back({u[i],c[i]});
}
ll bs=n+3;
vector<int> sol(n,0);
for(int i=0; i<n; i++)
{
vector<ll> v(n*2,0),lla(n*2,0);
vector<vector<ll>> ca(n*2+1);
queue<ll> q;
q.push(i);
while(!q.empty())
{
ll a=q.front();q.pop();
if(v[a]==0)
{
v[a]=2;
lla[r[a]]=1;
for(auto j:ca[r[a]])
{
q.push(j);
}
ca[r[a]].clear();
for(auto j:cad[a])
{
if(lla[j.second]==1)
{
q.push(j.first);
}
ca[j.second].push_back(j.first);
}
}
}
ll cont=0;
for(auto j:v)
{
if(j==2)
cont++;
//cout<<j<<" ";
}
//cout<<"\n";
sol[i]=cont;
bs=min(bs,cont);
}
for(int i=0; i<n; i++)
if(sol[i]==bs)
sol[i]=1;
else sol[i]=0;
return sol;
}
# | 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... |