A→B→C→Acap A right arrow cap B right arrow cap C right arrow cap A
: Iterate through your sorted pairs. For each pair, check if locking it (setting locked[i][j] = true ) would create a path from the loser back to the winner.
, add that pair to the pairs array and increment pair_count .
The most complex part of the solution is lock_pairs . The goal is to create a directed graph (the locked adjacency matrix) without creating a "cycle" (a loop where
A→B→C→Acap A right arrow cap B right arrow cap C right arrow cap A
: Iterate through your sorted pairs. For each pair, check if locking it (setting locked[i][j] = true ) would create a path from the loser back to the winner. Cs50 Tideman Solution
, add that pair to the pairs array and increment pair_count . A→B→C→Acap A right arrow cap B right arrow
The most complex part of the solution is lock_pairs . The goal is to create a directed graph (the locked adjacency matrix) without creating a "cycle" (a loop where Cs50 Tideman Solution