# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
439985 | haojiandan | Keys (IOI21_keys) | C++17 | 1222 ms | 51568 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 <bits/stdc++.h>
#include "keys.h"
using namespace std;
#define MP make_pair
const int maxn=(3e5)+10;
int n,m,p[maxn],r[maxn],fa[maxn];
int sz[maxn];
int find(int x) { if (fa[x]==x) return x; return fa[x]=find(fa[x]); }
bool have[maxn],vis[maxn],mk[maxn];
int hd,tl,q[maxn];
vector<pair<int,int> > g[maxn];
vector<int> vec[maxn];
vector<int> ans;
int bfs(int s,bool flag=0) {
hd=1,tl=0; int res=0;
q[++tl]=s,vis[s]=1;
while (hd<=tl) {
int x=q[hd]; hd++;
if (!have[r[x]]) {
while (!vec[r[x]].empty()) {
int y=vec[r[x]].back();
if (find(y)!=s) res=find(y);
if (!vis[y]) q[++tl]=y,vis[y]=1;
vec[r[x]].pop_back();
}
have[r[x]]=1;
}
for (pair<int,int> A : g[x]) {
int y=A.first;
if (have[A.second]) {
# | 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... |