제출 #837501

#제출 시각아이디문제언어결과실행 시간메모리
837501NothingXDThousands Islands (IOI22_islands)C++17
9.10 / 100
26 ms7500 KiB
#include "islands.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void debug_out(){cerr<<endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e5 + 10;

int n, m, h[maxn];
vector<pii> g[maxn];
bool vis[maxn];

bool dfs(int v, int p = -1){
	int cnt = g[v].size();
	if (p != -1) cnt--;
	if (cnt == 2) return true;
	vis[v] = true;
	for (auto [u, w]: g[v]){
		if (!vis[u]){
			h[u] = h[v] + 1;
			if (dfs(u, w)) return true;
		}
		else if (w != p && h[u] < h[v]){
		//	debug(v, u);
			return true;
		}
	}
	return false;
}

std::variant<bool, std::vector<int>> find_journey(
    int N, int M, std::vector<int> U, std::vector<int> V) {

	//if (n < 2)
	n = N, m = M;
	for (int i = 0; i < m; i++){
		g[U[i]].push_back({V[i], i/2});
	}
	return dfs(0);
}
#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...