1 条题解
-
1
用容器vector即可,vector之前在我的题解中讲过,所以不讲了
#include <bits/stdc++.h> using namespace std; int n, m, sum; vector<int> v[100005]; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; v[x].push_back(y); } for (int i = 1; i <= n; i++) { sort(v[i].begin(), v[i].end()); cout << v[i].size() << " "; for (int j = 0; j < v[i].size(); j++) cout << v[i][j] << " "; cout << endl; } return 0; }
- 1
信息
- ID
- 497
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 2
- 标签
- 递交数
- 29
- 已通过
- 23
- 上传者