不会了求调
查看原帖
不会了求调
790425
Administrator2023楼主2024/11/23 10:02
#include <bits/stdc++.h>
using namespace std;
struct node {
	int q;
	int o[1005];
} d[1005];
int p[1005][1005];
int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	int u, v;
	for(int i = 1; i <= m; i ++) {
		cin >> u >> v;
		p[u][v] = 1, p[v][u] = 1;
		d[u].q++, d[v].q++, d[u].o[i] = v, d[v].o[i] = u;
	}
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j <= n; j ++) 
			cout << p[i][j] << ' ';
		cout << endl;
	}
	for(int i = 1; i <= n; i ++) {
		cout << d[i].q << ' ';
		for(int j = 1; j <= d[i].q; j ++) 
			cout << d[j].o[j] << ' ';
		cout << endl;
	}
	
	return 0;
}
2024/11/23 10:02
加载中...