스택 오버플론가 뜨면서 런타임 오류가 생기네요
그래서 배열을 약간 키워줬는데도 오류가 생깁니다. 왜 그런걸까요?
고수님들 가르쳐주세요
~~~ c++
#include
#include
#include
#include
using namespace std;
int t, n, a;
int cache[101], S[100];
int lis3(int start) {
int& ret = cache[start+1];
if (ret != -1) return ret;
ret = 1;
for (int next = start + 1; next < n; next++) {
if (start==-1||S[start] < S[next]) ret = max(ret, lis3(next) + 1);
}
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
for (int i = 0; i < t; i++) {
cin >> n;
memset(S, -1, sizeof(S));
memset(cache, -1, sizeof(cache));
for (int j = 0; j < n; j++) {
cin >> S[j];
}
cout << lis3(-1)-1<<endl;
}
ieehyeon
스택 오버플론가 뜨면서 런타임 오류가 생기네요
그래서 배열을 약간 키워줬는데도 오류가 생깁니다. 왜 그런걸까요?
고수님들 가르쳐주세요
~~~ c++
#include
#include
#include
#include
using namespace std;
int t, n, a;
int cache[101], S[100];
int lis3(int start) {
int& ret = cache[start+1];
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
}
~~~
7년 전