为什么有“未知错误”
查看原帖
为什么有“未知错误”
926722
AlexKun楼主2023/3/8 00:05

评测所有的点都能AC,但是它不显示通过了,说“Unknown Error”。。。求解惑

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n , d , ans = 2e9;
bool f[105];
void dfs(int step , int pos)//pos表示前step-1次跳到了哪
{
	if(pos > n) return;
	if(pos == n)
	{
		ans = min(ans , step - 1);
		return;
	}
	for(int i = 1; i <= d; i++)
	{
		if(f[pos + i] == true)
		{
			dfs(step + 1 , pos + i);
		}
		else continue;
	}
}
int main()
{
	cin >> n >> d;
	for(int i = 1; i <= n; i++)
	{
		scanf("%1d" , &f[i]);
	}
	dfs(1 , 1);
	if(ans == 2e9) cout << -1;
	else cout << ans;
	return 0;
}
2023/3/8 00:05
加载中...