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>
#include <variant>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using ll = int;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define ln "\n"
std::variant<bool, std::vector<int>> find_journey(int N, int M, std::vector<int> U, std::vector<int> V) {
vii edge(N), index(N);
rep(i,0,M){
edge[U[i]].pb(V[i]);
index[U[i]].pb(i);
}
vi ans;
bool flag = false;
{
ll now = 0;
while(true){
vi ind, nex;
rep(i,0,edge[now].size()){
if(ans.empty() || (ans.back()^1) != index[now][i]){
ind.pb(index[now][i]);
nex.pb(edge[now][i]);
}
}
if(ind.size() == 0) break;
if(ind.size() == 1){
now = nex[0];
continue;
}
ll len = ans.size();
rep(i,0,2){
ans.pb(ind[i]);
ans.pb(ind[i]^1);
}
rep(i,0,2){
ans.pb(ind[i]^1);
ans.pb(ind[i]);
}
per(i,len-1,0) ans.pb(ans[i]);
break;
}
}
if(flag) return ans;
else return false;
}
# | 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... |