Cod sursa(job #3316749)

Utilizator domdiridomdidomDominik domdiridomdidom Data 20 octombrie 2025 14:59:52
Problema Algoritmul Bellman-Ford Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.53 kb
#include <fstream>
#include <vector>
#include <utility>

using std::vector;

struct Node{
    vector<std::pair<int, int>> edges;
    Node(){ }
    void addEdge(std::pair<int, int> x){
        edges.push_back(x);
    }
};

int main(){
    std::ifstream bem("bellmanford.in");
    std::ofstream kim("bellmanford.out");
    int n, m;
    bem >> n >> m;
    Node * nodes = new Node[m];
    for(int i = 0; i < m; i++){
        int x, y, cost;
        bem >> x >> y >> cost;
        nodes[x].addEdge({y, cost});
    }
}