# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1215118 | dosts | Thousands Islands (IOI22_islands) | C++20 | 0 ms | 0 KiB |
#include "islands.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
#define big(x) ((int)(x.size()))
using namespace std;
const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9;
vi edges[LIM],vis(LIM,0),mark(LIM,0);
int found =0;
void bandfs(int node,int p = -1) {
if (vis[node]) return;
vis[node] = 1;
for (auto it : edges[node]) {
if (it == p) continue;
if (!it) continue;
if (mark[it]) {
found = 1;
return;
}
bandfs(it,node);
}
}
void dfs(int node,int p = -1) {
if (vis[node]) return;
vis[node] = 1;
for (auto it : edges[node]) {
if (it == p) continue;
if (!it) {
found = 1;
return;
}
dfs(it,node);
}
}
std::variant<bool, std::vector<int>> find_journey(int N, int M, std::vector<int> U, std::vector<int> V) {
int come = 0,go = 0;
for (int i = 0;i<M;i++) {
if (!U[i]) go++;
else come++;
}
if (go >= 3 && come >= 1) return {0};
if (go >= 2 && come >= 3) return {0};
return false;
}