3 //number of lines
1 2
2 1
4 5
I want to store the n lines as a 2d vector, what is the best way to do it?
3 //number of lines
1 2
2 1
4 5
I want to store the n lines as a 2d vector, what is the best way to do it?
int t;
cin>>t;
std::vector<std::vector<int>> Vec(t, std::vector<int>(2, 0)); // replace zero with some value if you wanna intiallize vector.
for(int i=0; i<t; i++){
for(int j=0; j<2; j++{
cin>>Vec[i][j];
}
}
this is the way i always intiallize a 2d vector and take input. I feel there is nothing more efficient.