Fading Coder

One Final Commit for the Last Sprint

Shortest Path with Color Transformations: Solving the JOI 2021 Final Robot Problem

We are given a connected undirected graph (or possibly disconnected) with N vertices and M edges. Each edge e connects u and v, has an integer color c, and a cost p for traversing it. However, at any vertex, if multiple incident edges share the same color, the robot cannot decide which path to take....

Implementing Dijkstra's Algorithm with a Min-Heap

Dijkstra's algorithm computes the shortest paths from a source node to all other nodes in a weighted graph with non‑negative edge weights. The procedure begins identical to SPFA: initialize all distances to infinity, set the source distance to zero, and mark the source as visited. Then, relax all ed...

Solution to AtCoder Beginner Contest 446

D - Max Straight This problem can be solved efficient using a hash map. Initially, I overcomplicated it by thinking about sorting and finding the longest increasing subsequence. However, a simple approach using a map workss perfectly. #include <bits/stdc++.h> using namespace std; int main() {...

Circular Counting and Multi-Source Dijkstra on Graphs

D. On AtCoder Conference Problem Statement There is a circular pond with circumference (M). A hut and (N) people are located around the pond. For a real number (x) ((0\leq x < M)), the point (x) is defined as the position clockwise at distance (x) from the hut. The (i)-th person is at point (A_i)...