【题目描述】
 请利用 STL vector 模拟邻接表存图,编程输出无向无权图各个顶点的度。
【输入样例】
 5 6
 1 3
 2 1
 1 4
 2 3
 3 4
 5 1
【输出样例】
 4
 2
 3
 2
 1
【算法分析】
 本例利用 STL vector 模拟实现邻接表。代码参见:
https://blog.csdn.net/hnjzsyjyj/article/details/101233249
https://blog.csdn.net/hnjzsyjyj/article/details/101233485
https://blog.csdn.net/hnjzsyjyj/article/details/101233779
https://blog.csdn.net/hnjzsyjyj/article/details/119895317
 本题给出的测试样例对应的示意图如下:

【算法代码】
#include <bits/stdc++.h>
using namespace std;
const int N=1e5;
vector<int> v[N];
int main() {
    int n,m;
    cin>>n>>m;
    int s,t; //i is node's name from 1
    for(int i=1; i<=m; i++) {
        cin>>s>>t;
        v[s].push_back(t);
        v[t].push_back(s);
    }
    for(int i=1; i<=n; i++) {
        cout<<v[i].size()<<endl;
    }
    
    return 0;
}
/*
in:
5 6
1 3
2 1
1 4
2 3
3 4
5 1
out:
4
2
3
2
1
*/
[参考文献】
https://blog.csdn.net/hnjzsyjyj/article/details/101233249
 https://blog.csdn.net/hnjzsyjyj/article/details/101233485
 https://blog.csdn.net/hnjzsyjyj/article/details/101233779
 https://blog.csdn.net/hnjzsyjyj/article/details/119895317



















