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 vis[N];
int st = -1;
int nd = -1;
void dfs(int v,int pr){
vis[v] = 1;
for(auto u:adj[v]){
if(st != -1)
return;
if(u.second.second == pr)
continue;
if(vis[u.first] == 2)
assert(0);
if(vis[u.first] == 1){
st = u.first;
nd = v;
return;
}
par[u.first] = u.second.first;
dfs(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++){
if(mp[V[i]][U[i]].size()){
adj[U[i]].push_back({V[i],{i,mp[V[i]][U[i]].back()}});
adj[V[i]].push_back({U[i],{mp[V[i]][U[i]].back(),i}});
mp[V[i]][U[i]].pop_back();
}else{
mp[U[i]][V[i]].push_back(i);
}
}
dfs(0,-1);
if(st == -1)
return false;
return true;
}
# | 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... |