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>
using namespace std;
std::variant<bool, std::vector<int>> find_journey(
int N, int M, std::vector<int> U, std::vector<int> V) {
vector<vector<pair<int,int>>> g(N);
for(int i = 0;i<M;i++) {
g[U[i]].push_back({V[i],i});
}
if(N == 2) {
if(g[0].size() < 2)return false;
if(g[1].size() == 0)return false;
vector<int> v;
v.push_back(g[0][0].second);
v.push_back(g[1][0].second);
v.push_back(g[0][1].second);
v.push_back(g[0][0].second);
v.push_back(g[1][0].second);
v.push_back(g[0][1].second);
return v;
}
else {
if(N <= 2) {
return false;
}
vector<vector<int>> a(N, vector<int>(N, -1));
for(int i = 0;i<M;i++) {
a[U[i]][V[i]] = i;
}
vector<int> ans={a[0][1], a[1][2], a[2][1], a[0][1], a[0][2], a[1][2], a[2][1], a[0][2]};
return ans;
}
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... |