回复:hustoj 还没搭建好,正在确认

30 views
Skip to first unread message

薛定谔的猫

unread,
Dec 23, 2011, 3:24:53 AM12/23/11
to hustoj
编译器已经讲的很清楚了
#include <cstdio>
#include <cstdlib>
 
------------------ 原始邮件 ------------------
发件人: "志刚 黄"<hzga...@gmail.com>;
发送时间: 2011年12月23日(星期五) 下午4:23
收件人: "hustoj"<hus...@googlegroups.com>;
主题: 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