hustoj 还没搭建好,正在确认

31 views
Skip to first unread message

志刚 黄

unread,
Dec 23, 2011, 3:23:29 AM12/23/11
to hustoj
为什么除了A+B
其他题目老是compileerror
Main.cc: In function 'int main()':
Main.cc:24: error: 'scanf' was not declared in this scope
Main.cc:32: error: 'memset' was not declared in this scope
Main.cc:38: error: 'printf' was not declared in this scope

代码如下

//[HNOI2006]Hero
#include<iostream>
using namespace std;
struct edge
{int to;edge *next;
}e[2010],*latest[1010],*pe;
int n,m,p,down[2010];
bool in[2010];
bool findroad(int x)
{ for (edge *i=latest[x];i;i=i->next)
if (!in[i->to])
{in[i->to]=1;
if (!down[i->to]||findroad(i->to))
{down[i->to]=x;
return 1;
}
}
return 0;
}
int main()
{ int i,a,b;
// freopen("hero.in","r",stdin);
// freopen("hero.out","w",stdout);
scanf("%d%d",&n,&m);
pe=e;
for (i=1;i<=m;++i)
{scanf("%d%d",&a,&b);
pe->to=a,pe->next=latest[i],latest[i]=pe,pe++;
pe->to=b,pe->next=latest[i],latest[i]=pe,pe++;
}
p=0;
memset(down,0,sizeof(down));
for (i=1;i<=m;++i)
{memset(in,0,sizeof(in));
if (!findroad(i)) break;
++p;
}
printf("%d\n",p);
// fclose(stdin);
// fclose(stdout);
return 0;
}
Reply all
Reply to author
Forward
0 new messages