Submission #632065

#TimeUsernameProblemLanguageResultExecution timeMemory
6320654123xr4323Thousands Islands (IOI22_islands)C++17
1.75 / 100
36 ms12036 KiB
#include <bits/stdc++.h>
#define mp make_pair
#define all(a) a.begin(),a.end()
#define X first
#define Y second
using namespace std;
using pii = pair <long long, long long>;
constexpr int maxn = 2e5 + 10;
constexpr int mod = 1000002022;
constexpr long long inf = 1e17 + 10;
 
int n, m;
vector <pii> graph [maxn];
bool used [maxn];
int tree = true;

inline void dfs (int v, int par = maxn) {
    used[v] = true;
    for (pii i : graph[v]) if ((i.Y ^ par) != 1) {
        if (used[i.X]) {
            tree = false;
            continue;
        }
        dfs (i.X, i.Y);
    }
}

variant <bool, vector <int>> find_journey (int N, int M, vector <int> U, vector <int> V) {
    n = N, m = M;
    for (int i = 0; i < m; ++i) {
        graph[U[i]].push_back (mp (V[i], i));
    }
    dfs (0);
    return !tree;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...