This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://cses.fi/problemset/task/1680 | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
void dfs(vector<vector<ll>> &graph, vector<bool> &visited, vector<ll> &topsort, ll u) { | |
if (visited[u]) return; | |
visited[u] = true; | |
for (ll i : graph[u]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://atcoder.jp/contests/abc292/tasks/abc292_d | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
void dfs(vector<vector<ll>> &graph, set<ll> &visited, ll &edgeCnt, ll u){ | |
if(visited.count(u)) return; | |
visited.insert(u); | |
edgeCnt += graph[u].size(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
void dfs(vector<vector<ll>> &graph, | |
vector<pair<ll, ll>> &bridges, | |
vector<bool> &isArt, | |
vector<bool> &visited, | |
vector<ll> &ids, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
// dp[i][0] = max matching if we don't take edge (i, i_children) | |
// dp[i][1] = max matching if we take edge (i, i_children) | |
ll dp[(size_t)2e5 + 1][2]; | |
void dfs(vector<vector<ll>> &tree, ll root, ll parent){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
template <typename T> | |
class segment_tree { | |
private: | |
vector<pair<T, T>> tree; // 0-indexed | |
T n; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
ll powMod(ll a, ll b, ll m) { | |
if (b == 0) { | |
return 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
using ll = long long; | |
ll powMod(ll a, ll b, ll m) { | |
ll res = 1; | |
while (b) { | |
if (b % 2) res = (res * a) % m; | |
a = (a * a) % m; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
class dfsTree { | |
private: | |
vector<vector<ll>> tree; | |
vector<ll> nums, tail, low, parent; | |
ll time = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
class SegmentTree { | |
private: | |
struct Node { | |
Node* _left; | |
Node* _right; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
class SegmentTree { | |
private: | |
struct Node { | |
Node* _left; | |
Node* _right; |