이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define SIZE 2005
using namespace std;
int n , m;
int ret[SIZE] , vis[SIZE] , res;
vector<pair<int,int> > graph[SIZE];
vector<int> wait[SIZE];
int key[SIZE] , chk[SIZE];
queue<int> q;
vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) {
vector<int> ans(r.size(), 1);
n = r.size() , m = u.size();
for (int i = 0; i < m; i++) {
int a = u[i] , b = v[i];
graph[a].push_back({b,c[i]}); graph[b].push_back({a,c[i]});
}
int mi = 1e9;
for (int S = 0; S < n; S++) {
memset(vis , 0 , sizeof(vis));
memset(key , 0 , sizeof(key));
memset(chk , 0 , sizeof(chk));
for (int i = 0; i < n; i++) wait[i].clear();
q.push(S), key[r[S]]=1, vis[S]=1, res=0;
while(!q.empty()) {
int here = q.front(); q.pop();
res++;
if (key[r[here]]==0) {
key[r[here]]=1;
for (auto t : wait[r[here]]) {
q.push(t);
vis[t]=1;
}
}
for (auto t : graph[here]) {
int there = t.first , isp = t.second;
if (key[isp]==1 && vis[there]==0) {
vis[there]=1;
q.push(there);
}
else {
if (chk[there] == 0) {
chk[there]=1;
wait[isp].push_back(there);
}
}
}
}
ret[S] = res;
mi = min(mi , res);
}
for (int i = 0; i < n; i++) if (ret[i] != mi) 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... |