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 namespace std;
int n, m;
vector<int> u;
vector<int> v;
vector<int> ans;
void solve1() {
vector<int> a;
vector<int> b;
for (int i = 0; i < m; i++) {
if (!u[i]) a.push_back(i);
else b.push_back(i);
}
if (a.size() < 2 || b.size() < 1) return;
ans = {a[0], b[0], a[1], a[0], b[0], a[1]};
}
void solve2() {
ans.resize(12);
for (int i = 0; i < m; i++) {
if (u[i] == 0 && v[i] == 1) ans[0] = ans[8] = i;
if (u[i] == 1 && v[i] == 0) ans[5] = ans[9] = i;
if (u[i] == 0 && v[i] == 2) ans[3] = ans[11] = i;
if (u[i] == 2 && v[i] == 0) ans[2] = ans[6] = i;
if (u[i] == 1 && v[i] == 2) ans[1] = ans[7] = i;
if (u[i] == 2 && v[i] == 1) ans[4] = ans[10] = i;
}
}
variant<bool, vector<int> > find_journey(int N, int M, vector<int> U, vector<int> V) {
n = N;
m = M;
u = U;
v = V;
if (n == 2) solve1();
else solve2();
if (ans.size()) return ans;
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... |