# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
450530 | leinad2 | Keys (IOI21_keys) | C++17 | 1490 ms | 20844 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 "keys.h"
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int> >adj[2010];
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 i, j, k;
for(i=0;i<m;i++)
{
adj[u[i]].push_back({v[i], c[i]});
adj[v[i]].push_back({u[i], c[i]});
}
vector<int>ans;ans.resize(n);
for(i=0;i<n;i++)
{
int chk[2010]={}, A[2010]={};vector<int>v;
v.push_back(i);chk[i]=1;A[r[i]]=1;
while(1)
{
bool flag=false;
for(j=0;j<v.size();j++)
{
int a=v[j];
for(auto k:adj[a])
{
if(A[k.second]==1&&chk[k.first]==0)
{
chk[k.first]=1;
A[r[k.first]]=1;
v.push_back(k.first);
flag=true;
}
}
}
if(flag==false)break;
}
for(j=0;j<n;j++)ans[i]+=chk[j];
}
int x=1e9;
for(i=0;i<n;i++)x=min(ans[i], x);
for(i=0;i<n;i++)ans[i]=(ans[i]==x);
return ans;
}
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... |