# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1044478 | Unforgettablepl | Keys (IOI21_keys) | C++17 | 3017 ms | 26168 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector<int> find_reachable(vector<int> r,vector<int> u,vector<int> v,vector<int> c){
int n = r.size();
int m = u.size();
int S = n;
vector<vector<pair<int,int>>> adj(n);
for(int i=0;i<m;i++){
adj[u[i]].emplace_back(v[i],c[i]);
adj[v[i]].emplace_back(u[i],c[i]);
}
vector<int> p(n);
for(int x=0;x<n;x++){
queue<int> q;
vector<bool> visited(n);
vector<vector<int>> advance(n);
vector<bool> recieved(n);
q.emplace(x);
while(!q.empty()){
auto curr = q.front();q.pop();
if(visited[curr])continue;
visited[curr]=true;
p[x]++;
if(!recieved[r[curr]]){
recieved[r[curr]]=true;
for(int&i:advance[r[curr]])q.emplace(i);
}
for(auto[i,col]:adj[curr])if(!visited[i]){
if(recieved[col])q.emplace(i);
else advance[col].emplace_back(i);
}
}
}
int ans = *min_element(p.begin(),p.end());
cerr << "DEBUG Answer: " << ans << endl;
vector<int> res(n);
for(int i=0;i<n;i++)if(p[i]==ans)res[i]=1;
return res;
}
Compilation message (stderr)
# | 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... |