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 "islands.h"
#include <bits/stdc++.h>
#define N 100005
using namespace std;
vector<pair<int,pair<int,int>>> adj[N];
map<int,vector<int>> mp[N];
int par[N];
int par2[N];
int vis[N];
vector<int> ans;
void dfs2(int v,int pr){
vis[v] = 1;
vector<pair<int,pair<int,int>>> tmp;
for(auto u:adj[v]){
if(ans.size())
return;
if(vis[u.first] == 2){
ans.push_back(0);
return;
}
if(vis[u.first] == 1)
continue;
par[u.first] = u.second.first;
par2[u.first] = v;
dfs2(u.first,u.second.first);
}
vis[v] = 2;
}
variant<bool, vector<int>> find_journey(int n, int m, vector<int> U, vector<int> V){
for(int i = 0;i<m;i++){
adj[U[i]].push_back({V[i],{i,i+1}});
}
dfs2(0,-1);
return ans.empty();
}
# | 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... |