이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
int n, m;
vector<pii> G[100100];
vi find_reachable(vi r, vi u, vi v, vi c) {
n = (int)r.size();
m = (int)c.size();
vi reach(n, 0);
for(int i = 0; i < (int)u.size(); i++){
G[u[i]].pb(mp(v[i], c[i]));
G[v[i]].pb(mp(u[i], c[i]));
}
for(int room = 0; room < n; room++){
queue<pair<int, vector<bool>>> q;
vector<bool> ini(n, false);
bool vis[n];
memset(vis, false, sizeof vis);
vis[room] = true;
ini[r[room]] = true;
q.push(mp(room, ini));
while(!q.empty()){
int at = q.front().first;
vector<bool> ava = q.front().second;
if(!ava[r[at]]) ava[r[at]] = true;
q.pop();
for(auto next : G[at]){
if(ava[next.second] && !vis[next.first]){
vis[next.first] = true;
q.push(mp(next.first, ava));
}
}
}
int cnt = 0;
for(int i = 0; i < n; i++){
if(vis[i]) cnt++;
}
reach[room] = cnt;
}
int sm = *min_element(reach.begin(), reach.end());
vi ans(n, 0);
for(int i = 0; i < n; i++){
if(reach[i] == sm)
ans[i] = 1;
}
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... |