/ Randle /

记录详情

Accepted

/in/foo.cc: In function 'int main()':
/in/foo.cc:98:12: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    if((1<<j-1)&k)add(i,j,1<<j-1);
           ~^~
/in/foo.cc:98:30: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    if((1<<j-1)&k)add(i,j,1<<j-1);
                             ~^~
/in/foo.cc:104:27: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   if(boy[i])ans+=1<<boy[i]-1;
                     ~~~~~~^~
# 状态 耗时 内存占用
#1 Accepted 16ms 29.113 MiB
#2 Accepted 18ms 28.25 MiB
#3 Accepted 18ms 27.348 MiB
#4 Accepted 70ms 27.594 MiB
#5 Accepted 75ms 28.113 MiB
#6 Accepted 280ms 27.984 MiB
#7 Accepted 344ms 28.719 MiB
#8 Accepted 525ms 28.855 MiB
#9 Accepted 539ms 28.996 MiB
#10 Accepted 558ms 27.996 MiB

代码

#include<bits/stdc++.h>
const int maxn=1e6;
inline const void read(int &a)
{
	a=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')
	{
		a=(a<<1)+(a<<3)+c-'0';
		c=getchar();
	}
}
inline const void write(int a)
{
	if(a>9)write(a/10);
	putchar(a%10+'0');
}
inline const int max(int a,int b)
{
	if(a>b)return a;
	else return b;
}
inline const int min(int a,int b)
{
	if(a<b)return a;
	else return b;
}
int n,d=0;
int point[maxn],next[maxn],to[maxn],len[maxn];
int exboy[maxn],exgirl[maxn],boy[maxn],girl[maxn],three[maxn];
bool visboy[maxn],visgirl[maxn];
const bool found(int p)
{
	visboy[p]=true;
	int side=point[p];
	while(side)
	{
		if(!visgirl[to[side]])
		{
			if(exboy[p]+exgirl[to[side]]==len[side])
			{	
				visgirl[to[side]]=true;
				if(!girl[to[side]]||found(girl[to[side]]))
				{
					girl[to[side]]=p;
					boy[p]=to[side];
					return true;
				}
			}
			else
				if(exboy[p]+exgirl[to[side]]-len[side]>0)
					three[to[side]]=min(three[to[side]],exboy[p]+exgirl[to[side]]-len[side]);
		}
		side=next[side];
	}
	return false;
}
void solve()
{
	for(int i=1;i<=n;i++)
	{
		memset(three,0x7f,sizeof(three));
		while(true)
		{	
			memset(visgirl,false,sizeof(visgirl));
			memset(visboy,false,sizeof(visboy));
			if(found(i))break;
			int minus=three[0];
			for(int j=1;j<=32;j++)if(!visgirl[j])minus=min(three[j],minus);
			if(minus==three[0])break;
			for(int j=1;j<=n;j++)if(visboy[j])exboy[j]-=minus;
			for(int j=1;j<=32;j++)
				if(visgirl[j])exgirl[j]+=minus;
		}
	}
}
inline const void add(int a,int b,int c)
{
	next[++d]=point[a];
	to[d]=b;
	point[a]=d;
	len[d]=c;
	exboy[a]=max(exboy[a],len[d]);
}
int main()
{
	memset(exboy,0,sizeof(exboy));
	memset(exgirl,0,sizeof(exgirl));
	memset(girl,0,sizeof(girl));
	memset(boy,0,sizeof(boy));
	read(n);
	int k;
	for(int i=1;i<=n;i++)
	{
		read(k);
		for(int j=1;j<=32;j++)
			if((1<<j-1)&k)add(i,j,1<<j-1);
	}
	solve();
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(boy[i])ans+=1<<boy[i]-1;
		else ans^=1;
	}
	write(ans);
	return 0;
}

信息

递交者
类型
递交
题目
奇数异或(国家集训队)
题目数据
下载
语言
C++
递交时间
2017-10-06 17:03:53
评测时间
2017-10-06 17:03:53
评测机
分数
100
总耗时
2445ms
峰值内存
29.113 MiB