Vectors (segmentation fault)

If i assign a size of around 100000 to a 2D vector…it shows dumped neither does the inbuilt maxsize works…

IF i don;t assign a size, the result does not get accepted showing SEGMENTATION FAULT for a size>10power5

how should I solve it???

Depending on the type of the data, a [100000][100000] matrix is going to take at least 10Gb of memory. You need to figure out a more efficient way of storing your data. Perhaps you don’t need all those columns?

1 Like

The maximum size of vector on online judge in general is,

In main/local function - (Roughly of the order of ~10^6)

When declared global - (Roughly of the order of ~10^8)

If you are thinking of a solution in which you have to declare a vector of size greater than this, then there must be some better solution/Algorithm to solve it. (Source)

Hope this helps!


Even if you dont get runtime error on declaring a vector this big, you are sure to get TLE because of performing this many operations in elements (assuming every element is operated artleast once)