Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==57386==ERROR: AddressSanitizer: attempting double-free on 0x616000000680 in thread T0: #0 0x4dc7a0 (/out/package/ex4+0x4dc7a0) #1 0x7f54c37f836d (/lib/x86_64-linux-gnu/libc.so.6+0x7e36d) #2 0x4db23d (/out/package/ex4+0x4db23d) #3 0x518827 (/out/package/ex4+0x518827) #4 0x514fe7 (/out/package/ex4+0x514fe7) #5 0x7f54c379bb96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) #6 0x41cab9 (/out/package/ex4+0x41cab9) 0x616000000680 is located 0 bytes inside of 552-byte region [0x616000000680,0x6160000008a8) freed by thread T0 here: #0 0x4dc7a0 (/out/package/ex4+0x4dc7a0) #1 0x7f54c37f836d (/lib/x86_64-linux-gnu/libc.so.6+0x7e36d) previously allocated by thread T0 here: #0 0x4dc970 (/out/package/ex4+0x4dc970) #1 0x7f54c37f8eb9 (/lib/x86_64-linux-gnu/libc.so.6+0x7eeb9) #2 0x515402 (/out/package/ex4+0x515402) #3 0x514fe7 (/out/package/ex4+0x514fe7) #4 0x7f54c379bb96 (/lib/x86_64-linux-gnu
Hints
Your answer may be identical to the JOJ answer in the first several lines.
However, the main problem you meet now is Runtime Error. And the exit code of your program is 1, which should be 0.
Please double check your code to solve this problem and try again.
Your Answer
JOJ Answer
STDOUT START 1 41 -117 -37 48 -62 -85 -78 72 -110 98 -82 -77 7 110 43 -115 80 88 -37 62 89 75 -110 80 -144 -4 94 137 14 -36 -48 -22 -75 135 -79 8 119 74 -152 -64 -126 -122 22 153 -69 9 -57 -160 -70 -120 39 17 -6 -39 -93 -80 40 31 -107 109 22 143 0 114 -94 -51 -59 14 187 -65 101 -51 129 0 67 -41 -55 -27 55 -33 -96 -147 102 -108 -15 -17 -31 84 42 -32 -15 -87 -75 119 29 71 122 25 41 25 132 67 62 -15 -17 67 -185 22 74 -141 18 -86 147 3 21 115 11 30 -6 76 173 19 31 84 22 -91 -5 38 -57 -59 -101 -32 -46 39 -186 69 91 -81 -83 -112 112 133 63 -171 -49 51 102 2 84 -34 121 -4 -148 140 19 -6 -106 -10 27 16 -63 182 -61 97 95 -104 -98 -4 -79 -13 -79 46 -17 -96 -94 124 -26 -67 -155 -30 -39 -23 -80 23 -46 -138 -47 10 25 -15 -22 45 149 -107 -44 83 -15 -11 16 89 -21 -15 39 -40 20 -133 -38 -44 8 22 28 95 170 66 -41 43 -95 35 72 -22 -43 90 -80 158 -68 -38 71 31 138 -71 18 -118 -34 -70 27 15 -2 6 -91 55 53 82 -65 1 167 73 -117 -3 -100 132 6 50 -18 28 -43 -133 -106 -147 19 40 -28 -128 97 -51 -140 99 15 16 -120 3 -29 74 149 -38