Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <vector>
- using namespace std;
- typedef long long ll;
- const int maxn = 105;
- vector<pair<int, int>> graph[maxn];
- int main() {
- int n; // number of nodes(vertices)
- cin >> n;
- int m; // number of edges
- cin >> m;
- for(int i = 0; i < m; i++) {
- int a, b, c;
- cin >> a >> b >> c;
- graph[a].push_back({b, c});
- graph[b].push_back({a, c});
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < graph[i].size(); j++) {
- cout << i << "-->" << graph[i][j].first << " = " << graph[i][j].second << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment