MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / start_end

Function start_end

code/graph/euler_path.cpp:5–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3vi adj[MAXV];
4int n, m, indeg[MAXV], outdeg[MAXV], res[MAXE + 1];
5ii start_end() {
6 int start = -1, end = -1, any = 0, c = 0;
7 rep(i,0,n) {
8 if (outdeg[i] > 0) any = i;
9 if (indeg[i] + 1 == outdeg[i]) start = i, c++;
10 else if (indeg[i] == outdeg[i] + 1) end = i, c++;
11 else if (indeg[i] != outdeg[i]) return ii(-1,-1); }
12 if ((start == -1) != (end == -1) || (c != 2 && c != 0))
13 return ii(-1,-1);
14 if (start == -1) start = end = any;
15 return ii(start, end); }
16bool euler_path() {
17 ii se = start_end();
18 int cur = se.first, at = m + 1;

Callers 1

euler_pathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected