very weird segmentation fault..pls explain it...

I solved a question from Kharagpur onsite replay Olympic_Village

I declared a vector as

vector< vector<pair<int,int> > > nation(m);

but never used it. Due to this single declaration, I am getting segmentation fault SIGSEGV - SIGSEGV_solution

however if I comment that line, it gives AC - ACsolution

I never used that vector at all in my code.

on running with the input as the sample test case given:

2

5 3

2 7

1 4

5 8

3 6

9 10

5 1 1 2 1 3 1 4 1 5 1

4 1 1 2 1 3 2 5 2

3 3 1 5 1 4 1

4 2

1 3

3 6

2 3

4 7

4 1 2 2 2 3 1 4 1

4 1 1 2 1 3 2 4 2

gdb says:

Program received signal SIGSEGV, Segmentation fault.

0x00007ffff758859c in free () from /lib/x86_64-linux-gnu/libc.so.6

(gdb) where

#0 0x00007ffff758859c in free () from /lib/x86_64-linux-gnu/libc.so.6

#1 0x0000000000403bfa in __gnu_cxx::new_allocator<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > >::deallocate (this=0x7fffffffe110, __p=0x6080b0) at /usr/include/c++/4.6/ext/new_allocator.h:98

#2 0x00000000004036dc in std::_Vector_base<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, std::allocator<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > > >::_M_deallocate (

this=0x7fffffffe110, __p=0x6080b0, __n=3) at /usr/include/c++/4.6/bits/stl_vector.h:156 

#3 0x0000000000402e44 in std::_Vector_base<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, std::allocator<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > > >::~_Vector_base (

this=0x7fffffffe110, __in_chrg=<optimized out>) at /usr/include/c++/4.6/bits/stl_vector.h:142 

#4 0x0000000000402138 in std::vector<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, std::allocator<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > > > >::~vector (this=0x7fffffffe110,

__in_chrg=<optimized out>) at /usr/include/c++/4.6/bits/stl_vector.h:351 

#5 0x00000000004018cd in main (argc=1, argv=0x7fffffffe298) at p1.cpp:23
0

however if I comment that line, it outputs really fine

Can anybody explain this weird behaviour?