# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
834754 | IS_Rushdi | Keys (IOI21_keys) | C++17 | 3012 ms | 2097152 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) {
vector<int> ans(r.size(), 1);
int n = r.size();
int m = u.size();
vector<vector<vector<int>>>a(n,vector<vector<int>>(n,vector<int>()));
int mn = 1e9;
vector<int>tmp(n,0);
for(int i = 0; i < m; i++){
a[v[i]][c[i]].push_back(u[i]);
a[u[i]][c[i]].push_back(v[i]);
}
for(int i = 0; i < n; i++){
vector<int>vis(n,-1);
queue<int>q;
set<int>keys;
q.push(i);
while(!q.empty()){
int node = q.front();
q.pop();
if(vis[node] == keys.size()) continue;
keys.insert(r[node]);
vis[node] = keys.size();
for(int key : keys){
for(int to : a[node][key]){
q.push(to);
}
}
}
for(int j = 0; j < n; j++){
// cout << vis[j] << ' ';
if(vis[j] != -1) tmp[i]++;
}
mn = min(mn,tmp[i]);
// cout << tmp[i] << endl;
}
for(int i = 0; i < n; i++){
if(tmp[i] == mn) ans[i] = 1;
else ans[i] = 0;
}
return ans;
}
// int main(){
// int n; cin >> n;
// vector<int>a(n);
// for(int i = 0; i < n; i++) cin >> a[i];
// int m; cin >> m;
// vector<int>b(m),c(m),d(m);
// for(int i = 0; i < m; i++) cin >> b[i];
// for(int i = 0; i < m; i++) cin >> c[i];
// for(int i = 0; i < m; i++) cin >> d[i];
// vector<int>ans = find_reachable(a,b,c,d);
// for(int i = 0; i < n; i++) cout << ans[i] << ' ';
// }
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... |