Hej,
Czy mógłby ktoś wyjaśnić i jak naprawić kod, aby ten błąd już się nie pokazywał?
Unhandled exception at 0x0022CD19 in zoo.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x01C02000).
Czyżby to było coś związanego ze stosem?
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;
#define MAXN 1000010
#define min(a,b) ((a) < (b) ? (a) : (b))
int i, j, m, n, x;
int kon[MAXN], mas[MAXN], odw[MAXN], poc[MAXN], tab[MAXN];
long long il, minc = 6500, mins, sum, wyn;
int main()
{
fstream text("input.in");
int mas[MAXN];
int minc = 6500;
vector<int> numbers;
int n = numbers[0];
int integer, i = 0;
while (text >> integer)
{
numbers.push_back(integer);
i++;
}
for (i = 1; i <= n; ++i)
{
numbers[i] = mas[i];
minc = min(minc, mas[i]);
}
for (i = n; i <= n + n; ++i)
numbers[i] = poc[i];
for (i = n + n; i <= n + n; ++i)
numbers[i] = kon[i];
for (i = 1; i <= n; ++i)
tab[poc[i]] = kon[i];
for (i = 1; i <= n; ++i)
if (!odw[i])
{
j = i;
mins = 6500;
il = 0;
sum = 0;
while (!odw[j])
{
mins = min(mins, mas[j]);
odw[j] = 1;
++il;
sum += (long long)mas[j];
j = tab[j];
}
wyn += (long long)min(sum + (il - 2)*mins, sum + mins + (il + 1)*minc);
}
cout << wyn;
system("pause");
return 0;
}