Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 为什么USACO上全过，这里会WA

Posted by 411789805 at 2009-12-21 16:55:06 on Problem 1274
RT,请高手过目

#include <cstdio>
#include <cstring>

int m,n,i,j,k,p;
int w[205][205],opp[205];
bool mark[205];
char d[1000];

bool Extend_Path(int u)
{
for (int i=1;i<=w[u][0];++i)
{
int v=w[u][i];
if (!mark[v])
{
mark[v]=1;
if (!opp[v] || Extend_Path(opp[v]))
{
opp[v]=u;
return 1;
}
}
}
return 0;
}

int main()
{
freopen("stall4.in","r",stdin);
freopen("stall4.out","w",stdout);

scanf("%d%d\n",&n,&m);
for (i=1;i<=n;++i)
{
gets(d);
int x=0,len=strlen(d),p=0;
for (j=0;j<len;++j)
{
if (d[j]>=48 && d[j]<=57) x=x*10+d[j]-48;
else
{
if (p!=0) w[i][++w[i][0]]=x;
else ++p;
x=0;
}
}
if (x!=0) w[i][++w[i][0]]=x;
}

int ans=0;
for (i=1;i<=n;++i)
{
memset(mark,0,sizeof(mark));
if (Extend_Path(i)) ++ans;
}
printf("%d\n",ans);
return 0;
}

Followed by: