fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m;
  6. cin >> n >> m;
  7.  
  8. vector<int> graph[n];
  9.  
  10. for (int i = 1; i <= m; i++) {
  11. int u, v;
  12. cin >> u >> v;
  13.  
  14. graph[u].push_back(v);
  15. graph[v].push_back(u);
  16. }
  17.  
  18. for (int i = 0; i < n; i++) {
  19. int degree = graph[i].size();
  20. cout << i << " " << degree << "\n";
  21. }
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
0 0
1 0