Notes
This function is in beta test. Please help improve it in the issues
here.
/in/ex3.cpp:12:9: runtime error: index 25000 out of bounds for type 'int [25000]' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /in/ex3.cpp:12:9 in ================================================================= ==38934==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff32d1b560 at pc 0x00000051db14 bp 0x7fff32b1a270 sp 0x7fff32b1a268 WRITE of size 4 at 0x7fff32d1b560 thread T0 #0 0x51db13 (/out/package/ex3+0x51db13) #1 0x51adea (/out/package/ex3+0x51adea) #2 0x7f9f4a5b3b96 (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) #3 0x41e1d9 (/out/package/ex3+0x41e1d9) Address 0x7fff32d1b560 is located in stack of thread T0 at offset 2101824 in frame #0 0x51b86f (/out/package/ex3+0x51b86f) This frame has 9 object(s): [32, 33) '__c.addr.i146' [48, 49) '__c.addr.i142' [64, 65) '__c.addr.i' [80, 600) 'f1' [736, 1248) 'f2' [1312, 1001312) 'arr1' [1001568, 2001568) 'arr2' [2001824, 2101824) 'temp' <== Memory access at offset 2101824 overflows
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
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 -88 84 19 -171