# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
836289 | SamAnd | Thousands Islands (IOI22_islands) | C++17 | 1 ms | 724 KiB |
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 <variant>
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
const int N = 1003, M = 200005;
vector<pair<int, int> > g[N];
bool c[N];
int p[N];
int pi[N];
vector<int> ans;
bool dfs(int x)
{
c[x] = true;
for (int i = 0; i < g[x].size(); ++i)
{
int h = g[x][i].fi;
int hi = g[x][i].se;
if (hi / 2 == pi[x] / 2)
continue;
if (!c[h])
{
p[h] = x;
pi[h] = hi;
if (dfs(h))
return true;
}
else
{
return true;
}
}
}
std::variant<bool, std::vector<int> > find_journey(int N, int M, std::vector<int> U, std::vector<int> V)
{
for (int i = 0; i < M; ++i)
{
g[U[i]].push_back(m_p(V[i], i));
}
p[0] = -1;
pi[0] = -1;
if (!dfs(0))
return false;
return ans;
}
Compilation message (stderr)
# | 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... |