foo.cc: In function 'int main()':
foo.cc:69:16: warning: iteration 5000 invokes undefined behavior [-Waggressive-loop-optimizations]
69 | head[i]=-1;
| ~~~~~~~^~~
foo.cc:68:20: note: within this loop
68 | for (int i=1; i<=5001; i++) {
| ~^~~~~~
foo.cc:69:16: warning: 'void* __builtin_memset(void*, int, long unsigned int)' forming offset [40008, 40015] is out of the bounds [0, 40008] of object 'head' with type 'long long int [5001]' [-Warray-bounds]
69 | head[i]=-1;
| ~~~~~~~^~~
foo.cc:20:5: note: 'head' declared here
20 | int head[5001];
| ^~~~
[Hydro](https://hydro.ac)提供评测服务