Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <queue>
- using namespace std;
- const int maxn = 1e5 + 10;
- vector<int> graph[maxn];
- int main() {
- int num_of_vertices;
- cin >> num_of_vertices;
- int num_of_edges;
- cin >> num_of_edges;
- for(int i = 0; i < num_of_edges; i++) {
- int a, b;
- cin >> a >> b;
- graph[a].push_back(b); // one directioanl
- graph[b].push_back(a); // two directioanal
- }
- for(int i = 0; i < num_of_vertices; i++) {
- cout << i << " --> ";
- for(int j = 0; j < (int) graph[i].size(); j++) {
- cout << graph[i][j] << ", ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement