全WA,但已过样例
查看原帖
全WA,但已过样例
787888
Channel_Choo楼主2023/9/15 17:20
#include <iostream>
using namespace std;
int map[1001][1001], a[1001];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1;i <= n;i++)
	{
		int x, y;
		cin >> x >> y;
		map[x][y] = 1;
		map[y][x] = 1;
	}
	for (int i = 1;i <= n;i++)
	{
		for (int j = 1;j <= n;j++)
		{
			cout << map[i][j] << " ";
			if (map[i][j])
			{
				a[i]++;
			}
		}
		cout << endl;
	}
	for (int i = 1;i <= n;i++)
	{
		cout << a[i] << " ";
		for (int j = 1;j <= n;j++)
		{
			if (map[i][j])
			{
				cout << j;
			}
			if (j == n)
			{
			    cout << endl;
			}
			else
			{
			    cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}
2023/9/15 17:20
加载中...