QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#515881#7020. The Kouga Ninja Scrollsqsc114WA 1905ms45320kbC++113.5kb2024-08-12 10:42:422024-08-12 10:42:43

Judging History

你现在查看的是最新测评结果

  • [2024-08-12 10:42:43]
  • 评测
  • 测评结果:WA
  • 用时:1905ms
  • 内存:45320kb
  • [2024-08-12 10:42:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
#define ll long long
#define lid (id<<1)
#define rid (id<<1|1)
int x[MAXN],y[MAXN],c[MAXN];
ll inff=1e18;
struct node
{
	ll k;int c;
};
struct seg
{
	int l,r;
	vector<node> x;
}tr[MAXN<<2];
bool cmp1(node x,node y)
{
	return x.k>y.k;
}
bool cmp2(node x,node y)
{
	return x.k<y.k;
}
vector<node> merges(vector<node> a,vector<node> b)
{
//	puts("in");
	vector<node> res;res.resize(8);
	node x[4]={a[0],a[1],b[0],b[1]};
	sort(x,x+4,cmp1);
	res[0]=x[0];res[1]={-inff,0};
	for(int i=1;i<=3;i++)
	{
		if(x[i].c==x[0].c)continue;
		res[1]=x[i];break;
	}
	x[0]=a[2],x[1]=a[3],x[2]=b[2],x[3]=b[3];
	sort(x,x+4,cmp2);
	res[2]=x[0];res[3]={inff,0};
	for(int i=1;i<=3;i++)
	{
		if(x[i].c==x[0].c)continue;
		res[3]=x[i];break;
	}
	x[0]=a[4],x[1]=a[5],x[2]=b[4],x[3]=b[5];
	sort(x,x+4,cmp1);
	res[4]=x[0];res[5]={-inff,0};
	for(int i=1;i<=3;i++)
	{
		if(x[i].c==x[0].c)continue;
		res[5]=x[i];break;
	}
	x[0]=a[6],x[1]=a[7],x[2]=b[6],x[3]=b[7];
	sort(x,x+4,cmp2);
	res[6]=x[0];res[7]={inff,0};
	for(int i=1;i<=3;i++)
	{
		if(x[i].c==x[0].c)continue;
		res[7]=x[i];break;
	}
//	puts("out");
	return res;
}
void pushup(int id)
{
	tr[id].x=merges(tr[lid].x,tr[rid].x);
}
void build(int id,int l,int r)
{
	tr[id].l=l,tr[id].r=r;
	if(l==r)
	{
//		puts("in");
		tr[id].x.resize(8);
		tr[id].x[0]={x[l]+y[l],c[l]};
		tr[id].x[1]={-inff,0};
		tr[id].x[2]={x[l]+y[l],c[l]};
		tr[id].x[3]={inff,0};
		tr[id].x[4]={x[l]-y[l],c[l]};
		tr[id].x[5]={-inff,0};
		tr[id].x[6]={x[l]-y[l],c[l]};
		tr[id].x[7]={inff,0};
//		puts("out");
		return;
	}
	int mid=l+r>>1;
	build(lid,l,mid);
	build(rid,mid+1,r);
	pushup(id);
}
void update(int id,int pos)
{
//	cout<<id<<" "<<pos<<endl;
	if(tr[id].l==tr[id].r)
	{
		int l=pos;
		tr[id].x[0]={x[l]+y[l],c[l]};
		tr[id].x[1]={-inff,0};
		tr[id].x[2]={x[l]+y[l],c[l]};
		tr[id].x[3]={inff,0};
		tr[id].x[4]={x[l]-y[l],c[l]};
		tr[id].x[5]={-inff,0};
		tr[id].x[6]={x[l]-y[l],c[l]};
		tr[id].x[7]={inff,0};
		return;
	}
	int mid=tr[id].l+tr[id].r>>1;
	if(pos>mid)update(rid,pos);
	else update(lid,pos);
	pushup(id);
}
vector<node> query(int id,int l,int r)
{
	if(l<=tr[id].l&&tr[id].r<=r)
		return tr[id].x;
	int mid=tr[id].l+tr[id].r>>1;
	if(r<=mid)return query(lid,l,r);
	if(l>mid)return query(rid,l,r);
	return merges(query(lid,l,mid),query(rid,mid+1,r));
}
int main()
{
//	freopen("seg.in","r",stdin);
//	freopen("seg.out","w",stdout);
	int T,n,m;scanf("%d",&T);
	for(int _=1;_<=T;_++)
	{
		printf("Case #%d:\n",_);
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++)
			scanf("%d%d%d",x+i,y+i,c+i);
		build(1,1,n);
		for(int i=1;i<=m;i++)
		{
			int opt,l,r,x,y,c,k;
			scanf("%d",&opt);
			if(opt==1)
			{
				scanf("%d%d%d",&k,&x,&y);
				::x[k]+=x;
				::y[k]+=y;
				update(1,k);
//				for(int i=0;i<8;i++)
//					cout<<tr[3].x[i].k<<" ";
//				puts("");
			}
			if(opt==2)
			{
				scanf("%d%d",&k,&c);
				::c[k]=c;
				update(1,k);
			}
			if(opt==3)
			{
				scanf("%d%d",&l,&r);
				vector<node> x=query(1,l,r);
//				for(int i=0;i<8;i++)
//					cout<<tr[2].x[i].k<<" ";
//				puts("");
				ll resx=0,resy=0;
				if(x[0].c==x[2].c)
					resx=max(x[0].k-x[3].k,x[1].k-x[2].k);
				else
					resx=x[0].k-x[2].k;
				if(x[4].c==x[6].c)
					resy=max(x[4].k-x[7].k,x[5].k-x[6].k);
				else
					resy=x[4].k-x[6].k;
				ll ans=max(resx,resy);
				ans=max(0ll,ans);
				printf("%lld\n",ans);
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 16304kb

input:

1
2 8
0 0 1
1 1 2
3 1 2
1 1 1 1
3 1 2
1 1 1 1
2 1 2
3 1 2
2 1 1
3 1 2

output:

Case #1:
2
0
0
2

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 1905ms
memory: 45320kb

input:

60
500 500
869676911 -813404481 62
-945322435 46069424 18
-178313683 -431754291 62
365370429 989841420 403
581432447 750507267 482
151389216 29933356 18
-526811063 -170809743 105
862783905 920464530 91
343253321 -871223893 192
403379791 828503986 91
775506325 -370049275 192
533550283 -577541037 482
...

output:

Case #1:
3685787673
3468859321
3333691523
3468859321
3333691523
3333691523
3961865677
4160346448
3515366597
4160346448
3751993658
4096942446
4010435644
3960896897
2383169926
3713864607
3617781469
4042556370
3173729474
4042556370
3707466685
3960896897
4160346448
3960896897
4042556370
3960896897
39608...

result:

wrong answer 14th lines differ - expected: '4554140217', found: '4010435644'