# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
450528 | leinad2 | Keys (IOI21_keys) | C++17 | 1 ms | 460 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(auto x:v)
{
for(auto y:adj[x])
{
if(A[y.second]==1&&chk[y.first]==0)
{
chk[y.first]=1;
A[r[y.first]]=1;
v.push_back(y.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... |