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;
#define pb push_back
#define loop(x, i) for (int i = 0; i < x; i++)
#define rev(x, i) for (int i = (int)x - 1; i >= 0; i--)
#define ALL(x) begin(x), end(x)
#define sz(x) (int)x.size()
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
variant<bool, vi> find_journey(int N, int M, vi U, vi V)
{
if (N == 2)
{
vi heen, terug;
loop(M, i)
{
if (U[i] == 0)
heen.pb(i);
else
terug.pb(i);
}
if (sz(heen) >= 2 && sz(terug) >= 1)
{
return vi{heen[0], terug[0], heen[1], heen[0], terug[0], heen[1]};
}
return false;
}
else
{
map<ii, int> ix;
loop(M, i) ix[{U[i], V[i]}] = i;
int i1 = -1, i2 = -1;
loop(N, i)
{
if (i1 > -1)
break;
if (!ix.count({0, i}))
continue;
loop(N, j)
{
if (i == j)
continue;
if (!ix.count({0, j}))
continue;
if (!ix.count({i, j}))
continue;
i1 = i;
i2 = j;
break;
}
}
if (i1 == -1)
return false;
vi a = {ix[{0, i1}], ix[{i1, i2}], ix[{i2, 0}]};
vi b = {ix[{0, i2}], ix[{i2, i1}], ix[{i1, 0}]};
vi res;
for (int p : a)
res.pb(p);
for (int p : b)
res.pb(p);
rev(3, i) res.pb(a[i]);
rev(3, i) res.pb(b[i]);
return res;
}
}
# | 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... |