# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
817028 | | aVe | Keys (IOI21_keys) | C++17 | | 3072 ms | 451328 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>
//#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... |