In addition to above
Do not initialise srand over and over againg
srand (time(NULL)); should be called once. Details
Use standard containers instead of raw arrays
std::array is excellent choice to store your data of known size. if you are using c++17 you don't even need to specify what or how many inside.
You probably need a queue or stack maybe
if I ...
Your code doesn't compile due to the invalid use of goto. Nevertheless, I have put in my thoughts.
Dont using namespace std & #include <bits/stdc++.h>
Why shouldn't I use using namespace std in C++
Why shouldn't I #include <bits/stdc++.h>?
You should always try to avoid these two statements.
Format your code properly
A very important part ...