Skip to content

Instantly share code, notes, and snippets.

@CsengerG
Last active December 22, 2015 16:17
Show Gist options
  • Select an option

  • Save CsengerG/386abcfe45fe724a1d48 to your computer and use it in GitHub Desktop.

Select an option

Save CsengerG/386abcfe45fe724a1d48 to your computer and use it in GitHub Desktop.
Reading a graph from the standard input in C++
#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