社区讨论
全WA求条必关
B3643图的存储参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @mkl2nnxo
- 此快照首次捕获于
- 2026/01/19 19:18 上个月
- 此快照最后确认于
- 2026/01/23 14:55 4 周前
CPP
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 6;
int n, m, mp[N][N], x, y;
vector<int> q[N];
int main() {
ios::sync_with_stdio(0), cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> x >> y, mp[x][y] = 1, mp[y][x] = 1, q[x].push_back(y), q[y].push_back(x);
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) cout << mp[i][j] << ' ';
cout << '\n';
}
for (int i = 1; i <= n; i++) {
sort(q[i].begin(), q[i].end());
cout << q[i].size();
for (int j = 0; j < (int)q[i].size(); j++) cout << ' ' << q[i][j];
cout << '\n';
}
return 0;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...