topic description
Assuming that the directed graph G is stored in an adjacency list, an algorithm is designed to find the out-degree of each vertex in the graph G.
enter
The first line is the number n of vertices in the graph, the second line is the number e of edges in the graph, and the third line is the data information of two vertices attached to an edge.
output
Out-degree of each vertex in graph G. The first line represents the out-degree of vertex 0, and the other lines have the same definition.
#include<bits/stdc++.h>
using namespace std;
vector<int>v[105];
int n, m, x, y;
int main(){
cin>>n>>m;
for(int i = 0; i < m; i++){
cin>>x>>y;
v[x].push_back(y);
}
for(int i = 0; i < n; i++) cout<<v[i].size()<<endl;
return 0;
}