# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1235622 | Ghulam_Junaid | Thousands Islands (IOI22_islands) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "islands.h"
#include "grader.cpp"
using namespace std;
const int N = 2e5 + 10;
int n, m, vis[N];
vector<int> g[N], V;
bool dfs(int v, int day){
if (v == 0) return 1;
vis[v] = day;
bool ans = 0;
for (int e : g[v]){
int u = V[e];
if (vis[u] == day) return 1;
ans |= dfs(u, day);
}
return ans;
}
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> vv) {
V = vv;
n = N, m = M;
for (int i = 0; i < m; i ++){
g[U[i]].push_back(i);
}
int day = 0, ans = 0;
for (int e : g[0]){
day++;
ans += dfs(V[e], day);
}
if (ans >= 2) return true;
return false;
if (N == 4) {
return vector<int>({0, 1, 2, 4, 0, 3, 2, 1, 4, 3});
}
return false;
}