Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <vector>
- using namespace std;
- typedef long long ll;
- const int maxn = 105;
- vector<int> graph[maxn];
- int main() {
- int n; // number of nodes(vertices)
- cin >> n;
- int m; // number of edges
- cin >> m;
- for(int i = 0; i < m; i++) {
- int a, b;
- cin >> a >> b;
- graph[a].push_back(b);
- graph[b].push_back(a);
- }
- vector<int> v = graph[0];
- vector<int> v1 = graph[1];
- for(int i = 0; i < n; i++) {
- cout << i << ": ";
- for(int j = 0; j < graph[i].size(); j++) {
- cout << graph[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment