2026-11-06 20:02:34
发布于:北京
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int n;
const int inf = 0x3f3f3f3f;
int m;
struct Edge{
int v;
int w;
};
vector<Edge> g[N];
int main(){
cin >> n >> m;
for (int i = 1; i <= m;i++){
int u;
int v;
int w;
cin >> u >> v >> w;
g[u].push_back({v,w});
}
for (int i = 1;i <= n;i++){
cout << i << ":";
for (auto j : g[i]){
int v = j.v;
int w = j.w;
printf("(%d,%d)",v,w);
}
cout << endl;
}
return 0;
}
/*
5 7
1 3 3
1 4 5
1 2 1
2 4 5
2 5 6
3 4 1
4 5 4
*/
这里空空如也













有帮助,赞一个