# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894859 | Muhammad_Aneeq | Keys (IOI21_keys) | C++17 | 3028 ms | 40900 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 <vector>
using namespace std;
int const N=3e5+10;
vector<pair<int,int>>nei[N]={};
int key[N]={};
int viskey[N]={};
int vis[N]={};
vector<int>req[N]={};
bool w=0;
void dfs(int n)
{
vis[n]=1;
viskey[key[n]]=1;
for (auto i:req[key[n]])
if (!vis[i])
dfs(i);
for (auto [i,w]:nei[n])
{
if (vis[i])
continue;
if (viskey[w]==0)
req[w].push_back(i);
else
dfs(i);
}
}
vector<int> find_reachable(vector<int> r,vector<int> u,vector<int> v,vector<int> c)
{
int n=r.size();
for (int i=0;i<u.size();i++)
{
nei[u[i]].push_back({v[i],c[i]});
nei[v[i]].push_back({u[i],c[i]});
}
for (int i=0;i<n;i++)
key[i]=r[i];
vector<int>f={};
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
req[j]={};
vis[j]=viskey[j]=0;
}
w=(i==5);
dfs(i);
int t=0;
for (int j=0;j<n;j++)
t+=vis[j];
f.push_back(t);
}
vector<int>ans={};
int z=n;
for (auto i:f)
z=min(z,i);
for (auto i:f)
ans.push_back((z==i?1:0));
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... |