QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#232639#6608. Descent of DragonsqwqwfRE 0ms0kbC++141006b2023-10-30 18:19:512023-10-30 18:19:51

Judging History

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

  • [2023-10-30 18:19:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-30 18:19:51]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define iter map<int,int>::iterator
using namespace std;
map<int,int> a;
int n,q;
int op,l,r,x;
iter split(int l)
{
	iter it=a.lower_bound(l);
	if(it->first==l) return it;
	return --it,a.insert(make_pair(l,it->second)).first;
}
int main()
{
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	scanf("%d %d",&n,&q);
	a.insert(make_pair(1,0));
	while(q--)
	{
		scanf("%d",&op);
		if(op==1)
		{
			scanf("%d %d %d",&l,&r,&x);
			iter begin=split(l),end=split(r+1);
			for(iter i=begin;i!=end;++i)
			{
				if(i->second==x) ++i->second;
				if(i->second!=begin->second)
					++begin,a.erase(begin,i),begin=i;
			}
		}
		else if(op==2)
		{
//			cout<<(int)a.size()<<'\n';
			int ans=0;
			scanf("%d %d",&l,&r);
			iter begin=a.upper_bound(l),end=a.upper_bound(r);
			for(iter i=--begin;i!=end;++i)
				ans=max(ans,i->second);
			printf("%d\n",ans);
		}
	}
	return 0;
}

详细

Test #1:

score: 0
Dangerous Syscalls

input:

5 5
1 3 5 0
1 1 4 1
1 1 5 2
2 2 2
2 4 5

output:


result: