Last active
December 22, 2015 16:17
-
-
Save CsengerG/386abcfe45fe724a1d48 to your computer and use it in GitHub Desktop.
Reading a graph from the standard input in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<bits/stc++.h> | |
| vector<int> g[MAXN];//Vectors storing our graph | |
| int main(void){ | |
| int n;//n - the number of vertexes in our graph | |
| int m;//m - the number of edges in our graph | |
| cin >> n >> m; | |
| for(int i=0;i<m;++i){ | |
| int a,b; | |
| cin >> a; a--; | |
| cin >> b; b--; | |
| g[a].push_back(b); | |
| g[b].push_back(a); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment