fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include <bits/stdc++.h>
  4. #include<vector>
  5.  
  6. int main() {
  7. // your code goes here
  8. int n,m;
  9. cin>>n>>m;
  10. vector<int>g[n];
  11. for(int i=1;i<=m;i++)
  12. {
  13. int x,y;
  14. cin>>x>>y;
  15. g[x].push_back(y);
  16. g[y].push_back(x);
  17. }
  18.  
  19. for(int i=0;i<n;i++)
  20. {
  21. int c = g[i].size();
  22. cout<<i<<" "<<c<<endl;
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 5288KB
stdin
4 3
0 1 
1 2 
2 3
stdout
0 1
1 2
2 2
3 1