Category : vector

#include <iostream> #include <cstdlib> #include <ctime> #include <chrono> #include <thread> #include <bits/stdc++.h> #include <pthread.h> #include <vector> #include<unistd.h> using namespace std; vector<vector<int> >matrix1c; vector<vector<int> >matrix2c; vector<vector<int> >matrix3c; int maxelement; int totalelement; int step_i = 0; int r1c; int c1c; int r2c; int c2c; void* multi(void* arg) { int core = step_i++; for (int i = core ..

Read more

https://www.hackerrank.com/challenges/variable-sized-arrays/problem Just learnt vectors and tried to implement the following code for the above question but it shows runtime error. Please help me figure out the problem in this code. #include<bits/stdc++.h> using namespace std; int main(){ int t,q; cin>>t>>q; vector<vector<int>> vect(t); while(t–){ int a; cin>>a; vector<int> v1(a); while(a–){ int num; cin>>num; v1.push_back(num); } vect.push_back(v1); } ..

Read more

https://www.hackerrank.com/challenges/variable-sized-arrays/problem I tried to implement the following code for the above question but it shows runtime error. I tried to find the problem, so I printed the vector. For example, if I tried to make vector like this {{2,3},{1}}, it printed {{0,0,2,3},{0,1}}. So I thought maybe "cin" inside the while loop was causing problem because ..

Read more

I am using a vector of class types for my school project. The vector is called knightVec and I can use some vector functions no prob, for example knightVec.size() or knightVec.push_back(…) but when I try to use knightVec.erase(1) (or any position) it throws this error: no instance of overloaded function "std::__1::vector<_Tp, _Allocator>::erase [with _Tp=Knight, _Allocator=std::__1::allocator<Knight>]" ..

Read more