Essential Graph Algorithms for Programming Contests
Dikjstra's Algorithm (Adjacency Matrix)
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX_NODES = 510;
int node_count, edge_count;
int graph[MAX_NODES][MAX_NODES];
int min_distance[MAX_NODES];
bool visited[MAX_NODES];
int dijkstra_shortest_path() {
memset(min_distance, 0x3f, s ...
Posted on Fri, 18 Sep 2026 16:11:15 +0000 by sledgeweb
Essential Algorithm Templates for Competitive Programming
Data Structures
Segment Tree
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 100010;
int n, m;
vector<ll> arr;
vector<ll> tree;
vector<ll> lazy;
inline ll read() {
ll x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ...
Posted on Tue, 28 Jul 2026 16:49:08 +0000 by Daggeth