3 solutions
-
1
#include <bits/stdc++.h> using namespace std; const int N =1e3; int main(){ int n,m; cin>>n>>m; vector<vector<int>> a(N, vector<int>(0)); while(m--){ int x,y; cin>>x>>y; a[x-1].push_back(y);//也是从0开始的 } for(int i = 0 ; i < n ; i++){ sort(a[i].begin(),a[i].end()); } for(int i = 0 ; i < n ; i++){ cout<<a[i].size()<<" "; for(int j = 0 ; j < a[i].size(); j++){ cout<<a[i][j]<<" "; } cout<<endl; } return 0; }
Information
- ID
- 837
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 2
- Tags
- # Submissions
- 41
- Accepted
- 27
- Uploaded By