could anybody check my code, it is throwing bad_alloc exception
#include <iostream>#include <vector>using namespace std;int main() {int n, k = 1, i = 1;cin >> n;int p[n+5];vector <int> vv[n+5];bool visited[n+5];for (int i = 1; i <= n; ++i) visited[i] = false;visited[1] = true;for (int j = 1; j <= n; ++j) cin >> p[j];int x = p[i];while (i != n+1) {
Read more… (10 words)