# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966271 | AkibAzmain | Keys (IOI21_keys) | C++17 | 3028 ms | 21560 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>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
std::vector<int>
find_reachable (std::vector<int> r, std::vector<int> u,
std::vector<int> v, std::vector<int> c) {
vector < vector < pair < int, int > > > adj (r.size ());
for (int i = 0; i < c.size (); ++i)
adj[u[i]].push_back ({ v[i], c[i] }),
adj[v[i]].push_back ({ u[i], c[i] });
map < int, vector < int > > a;
for (int i = 0; i < r.size (); ++i)
{
set < int > kr;
map < int, vector < int > > pd;
vector < bool > vs (r.size ());
int cnt = 0;
queue < int > q;
q.push (i);
while (!q.empty ())
{
int x = q.front ();
q.pop ();
if (vs[x]) continue;
vs[x] = true;
++cnt;
kr.insert (r[x]);
for (auto &x : pd[r[x]]) q.push (x);
pd[r[x]].clear ();
for (auto &c : adj[x])
if (kr.count (c.second))
q.push (c.first);
else pd[c.second].push_back (c.first);
}
a[cnt].push_back (i);
}
vector < int > ans (r.size ());
for (auto &x : a.begin ()->second) ans[x] = 1;
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... |