QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#232639 | #6608. Descent of Dragons | qwqwf | RE | 0ms | 0kb | C++14 | 1006b | 2023-10-30 18:19:51 | 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;
}
Details
Tip: Click on the bar to expand more detailed information
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