# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
443376 | leinad2 | Keys (IOI21_keys) | C++17 | 1775 ms | 17092 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, i, j, k, m, a, b;
n=r.size();m=c.size();
vector<int>ans;
ans.resize(n);
for(i=0;i<m;i++)
{
adj[u[i]].push_back({v[i], c[i]});
adj[v[i]].push_back({u[i], c[i]});
}
for(i=0;i<n;i++)
{
int chk[2010]={}, A[2010]={};
chk[i]=1;A[r[i]]=1;vector<int>v;v.push_back(i);
while(1)
{
bool flag=false;
for(j=0;j<v.size();j++)
{
a=v[j];
for(k=0;k<adj[a].size();k++)
{
if(A[adj[a][k].second]==1&&chk[adj[a][k].first]==0)
{
chk[adj[a][k].first]=1;
A[r[adj[a][k].first]]=1;
v.push_back(adj[a][k].first);
flag=true;
}
}
}
if(!flag)break;
}
for(j=0;j<n;j++)ans[i]+=chk[j];
}
int x=1e9;for(i=0;i<n;i++)x=min(x, ans[i]);
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... |