/ Randle /

记录详情

Wrong Answer

/in/foo.cc: In function 'void build(long long int, long long int, long long int)':
/in/foo.cc:119:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  LL mid=l+r>>1;
         ~^~
/in/foo.cc: In function 'void modify(long long int, long long int, long long int, long long int, long long int)':
/in/foo.cc:127:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  LL mid=l+r>>1;
         ~^~
/in/foo.cc: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)':
/in/foo.cc:135:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  LL mid=l+r>>1,ans=0;
         ~^~
# 状态 耗时 内存占用
#1 Wrong Answer 4ms 2.352 MiB
#2 Wrong Answer 4ms 340.0 KiB
#3 Wrong Answer 6ms 2.375 MiB
#4 Wrong Answer 5ms 2.375 MiB
#5 Wrong Answer 14ms 2.465 MiB
#6 Wrong Answer 7ms 2.375 MiB
#7 Wrong Answer 13ms 2.488 MiB
#8 Wrong Answer 11ms 2.375 MiB
#9 Wrong Answer 12ms 2.613 MiB
#10 Wrong Answer 16ms 2.473 MiB
#11 Wrong Answer 47ms 4.527 MiB
#12 Wrong Answer 40ms 6.309 MiB
#13 Wrong Answer 130ms 4.5 MiB
#14 Wrong Answer 681ms 6.43 MiB
#15 Wrong Answer 128ms 6.559 MiB
#16 Wrong Answer 76ms 4.559 MiB
#17 Wrong Answer 304ms 6.434 MiB
#18 Wrong Answer 217ms 6.5 MiB
#19 Wrong Answer 158ms 5.125 MiB
#20 Wrong Answer 291ms 5.305 MiB

代码

#include<bits/stdc++.h>
#define LL long long
inline void read(LL&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 void write(LL a)
{
	if(a<0){a=-a;putchar('-');}
	if(a>=10)write(a/10);
	putchar(a%10+'0');
}
inline bool get_order()
{
	char c=getchar();bool b;
	while(c<'a'||c>'z')c=getchar();
	if(c=='a')b=true;
	else b=false;
	while(c>='a'&&c<='z')c=getchar();
	return b;
}
#define pmaxn 6001
#define smaxn 210001
struct side
{
	LL from,to,len,next;
}s[smaxn];
inline const bool comp(const side&a,const side&b)
{
	if(a.len<b.len)return true;
	return false;
}
LL n,m,q,k=0;
LL next[pmaxn<<3],to[pmaxn<<3],len[pmaxn<<3];
LL point[pmaxn],d=0,big_side_a;
inline void add(LL a,LL b,LL c)
{
	next[++d]=point[a];
	point[a]=d;
	to[d]=b;
	len[d]=c;
}
LL belong[pmaxn];
inline LL check(LL a)
{
	if(a==belong[a])return a;
	return belong[a]=check(belong[a]);
}
inline void init()
{
	d=0;
	for(LL i=1;i<=n;i++){belong[i]=i;point[i]=0;}
}
inline LL least_tree()
{
	init();
	LL group=n-1,i=0;
	std::sort(s+1,s+1+k,comp);
	while(group)
	{
		++i;
		if(check(s[i].from)==check(s[i].to))continue;
		group--;
		belong[check(s[i].from)]=s[i].to;
		add(s[i].from,s[i].to,s[i].len);
		add(s[i].to,s[i].from,s[i].len);
	}
	return s[i].len;
}
LL ansa,ansb;
LL son[pmaxn],num[pmaxn],father[pmaxn],top[pmaxn],deep[pmaxn];
inline void dfs1(LL p)
{
	son[p]=num[p]=0;
	LL side=point[p];
	while(side)
	{
		if(to[side]!=father[p])
		{
			father[to[side]]=p;
			deep[to[side]]=deep[p]+1;
			dfs1(to[side]);
			num[p]+=num[to[side]];
			if(num[to[side]]>num[son[p]])son[p]=to[side];
		}
		side=next[side];
	}
}
LL loc[pmaxn],leaf[pmaxn],rt,wei[pmaxn];
inline void dfs2(LL p,LL tp)
{
	top[p]=tp;
	leaf[++rt]=wei[p];loc[p]=rt;
	if(son[p])dfs2(son[p],tp);
	LL side=point[p];
	while(side)
	{
		if(to[side]!=father[p]&&to[side]!=son[p]){wei[to[side]]=len[side];dfs2(to[side],to[side]);}
		side=next[side];
	}
}
#define root 1,1,n
#define lson p<<1,l,mid
#define rson p<<1|1,mid+1,r
LL big[pmaxn<<2];
inline void update(LL p)
{
	big[p]=std::max(big[p<<1],big[p<<1|1]);
}
inline void build(LL p,LL l,LL r)
{
	if(l==r){big[p]=leaf[++rt];return ;}
	LL mid=l+r>>1;
	build(lson);
	build(rson);
	update(p);
}
inline void modify(LL p,LL l,LL r,LL loc,LL change)
{
	if(l==r){big[p]=change;return ;}
	LL mid=l+r>>1;
	if(loc<=mid)modify(lson,loc,change);
	else modify(rson,loc,change);
	update(p);
}
inline LL query(LL p,LL l,LL r,LL ll,LL rr)
{
	if(l>=ll&&r<=rr)return big[p];
	LL mid=l+r>>1,ans=0;
	if(mid>=ll)ans=std::max(query(lson,ll,rr),ans);
	if(mid+1<=rr)ans=std::max(query(rson,ll,rr),ans);
	return ans;
}
inline LL get_ans(LL x,LL y)
{
	LL ans=0;
	while(top[x]!=top[y])
	{
		if(deep[top[x]]<deep[top[y]])std::swap(x,y);
		ans=std::max(query(root,loc[top[x]],loc[x]),ans);
		x=father[top[x]];
	}
	if(deep[x]<deep[y])std::swap(x,y);
	ans=std::max(query(root,loc[y],loc[x]),ans);
	return ans;
}
int main()
{
	read(n);read(m);
	LL u,v,l,m1,m2,b1,b2;
	for(LL i=1;i<=m;i++)
	{
		read(u);read(v);read(l);
		s[++k].from=u;s[k].to=v;s[k].len=l;
	}
	big_side_a=least_tree();
	deep[1]=0;
	dfs1(1);
	rt=0;wei[1]=0;
	dfs2(1,1);
	rt=0;
	build(root);
	read(q);
	q=30;
	while(q--)
	{
		if(get_order())
		{
			read(u);read(v);read(l);
			s[++k].from=u;s[k].to=v;s[k].len=l;
			if(s[k].len<big_side_a)
			{
				big_side_a=least_tree();
				deep[1]=0;
				dfs1(1);
				rt=0;wei[1]=0;
				dfs2(1,1);
				rt=0;
				build(root);
			}
		}
		else
		{
			read(m1);read(m2);
			ansa=get_ans(m1,m2);
			read(b1);read(b2);
			ansb=get_ans(b1,b2);
			if(ansa==ansb)puts("Baozika");
			else puts("madoka");
		}
	}
	return 0;
}

信息

递交者
类型
递交
题目
玩游戏(CQ直辖市noip模拟赛联考) T2
题目数据
下载
语言
C++
递交时间
2017-11-04 17:22:49
评测时间
2017-11-04 17:23:20
评测机
分数
0
总耗时
2173ms
峰值内存
6.559 MiB