我的代码如下,已在vs2015下运行成功,为什么在PAT上提交后会显示编译错误呢?:
#include
using namespace std;
const int max_int = 500;
int teams[max_int], map[max_int][max_int],visited[max_int];
int city, roads, src, dst;
int min;
int max;
int num;
void dfs(int src,int dst,int dist,int team)
{
if (src == dst)
{
if (dist < min)
{
num = 1;
min = dist;
max = team;
}
else if (dist == min)
{
num++;
if (team > max)
max = team;
}
else
;
}
else
{
for (int i = 0;i < city;i++)
{
if (visited[i] == 0 && map[src][i] < city)
{
visited[i] = 1;
dfs(i, dst, dist + map[src][i], team + teams[i]);
visited[i] = 0;
}
}
}
}
int main() {
cin >> city >> roads >> src >> dst;
min = city;
max = 0;
for (int i = 0;i < city;i++)
{
cin >> teams[i];
}
for (int i = 0;i < city;i++)
{
visited[i] = 0;
}
for(int i=0;i
for (int j = 0;j
{
map[i][j] = city;
}
int x, y, d;
for (int i = 0;i
{
cin >> x >> y >> d;
map[x][y] = d;
map[y][x] = d;
}
dfs(src, dst, 0, teams[src]);
cout << num << " " << max;
system("pause");
return 0;
}