- Miku_Nobody
- 2015-12-23 13:51:29 @
#include<cstdio>
#include<cstring>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
using namespace std;
int n,m,v,ans=0,f[500],c[500];
bool used[500];
struct edge
{
int v;
edge *nxt;
}pool[100000],*tp=pool,*head[500];
bool judge(int x)
{
for(edge *i=head[x]; i; i=i->nxt)
if(!used[v=i->v])
{
used[v]=1;
if(!c[v] || judge(c[v]))
{
c[v]=x;
return 1;
}
}
return 0;
}
bool addedge(long long x){for(long long i=1; i<=x; i<<=1)if(i==x)return 1;return 0;}
int main()
{
scanf("%d%d",&n,&m);
rep(i,1,n)
scanf("%d",f+i);
rep(i,n+1,n+m)
{
scanf("%d",f+i);
rep(j,1,n)
if(addedge(f[i]+f[j]+1))
*tp=(edge){i,head[j]},head[j]=tp++;
}
rep(i,1,n)
{
memset(used,0,sizeof(used));
if(judge(i))
++ans;
}
if(ans)
printf("%d\n",ans);
else printf("I want nobody nobody but you\n");
return 0;
}