在codeforces上wa on test 29,wrong answer participant doesn't have number 145019 on 4002 query
,record
#include<bits/stdc++.h>
using namespace std;
#define pc putchar
template<typename T> inline void fr(T& num){
num=0;short sign=1;char ch=std::getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')sign=-1;
ch=std::getchar();
}
while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
num=num*sign;
}
template<typename T>inline void fw(T x){
if(x<0)std::putchar('-'),x=-x;
if(x>9)fw(x/10);
std::putchar(x%10+'0');
}
const int N=1<<18;
int n,m,p;
inline vector<pair<int,int> >operator+(const vector<pair<int,int> >& a,const vector<pair<int,int> >& b){
vector<pair<int,int> >res,ans;
for(auto [xcnt,x]:a){
for(auto [ycnt,y]:b){
xcnt+=(x==y)*ycnt;
}
res.emplace_back(xcnt,x);
}
for(auto [ycnt,y]:b){
bool flag=1;
for(auto [xcnt,x]:a){
flag&=x!=y;
}
if(flag)res.emplace_back(ycnt,y);
}
sort(res.begin(),res.end(),greater<pair<int,int> >());
for(int i=0;i<min((signed)res.size(),100/p);i++)ans.emplace_back(res[i]);
return ans;
}
int a[N];
namespace seg{
struct node{
int l,r,lz;
vector<pair<int,int> >val;
inline void operator=(int x){
lz=x;
val.clear();
val.emplace_back(r-l+1,x);
}
}t[N<<2];
#define ls(p) p<<1
#define rs(p) p<<1|1
inline void pushup(int p){
t[p].val=t[ls(p)].val+t[rs(p)].val;
}
inline void pushdown(int p){
if(t[p].lz){
t[ls(p)]=t[p].lz;
t[rs(p)]=t[p].lz;
t[p].lz=0;
}
}
inline void build(int p,int l,int r){
if((t[p].l=l)==(t[p].r=r)){
return t[p]=a[l],void();
}
int mid=l+r>>1;
build(ls(p),l,mid);
build(rs(p),mid+1,r);
pushup(p);
}
inline vector<pair<int,int> > query(int p,int l,int r){
if(l<=t[p].l&&t[p].r<=r)return t[p].val;
pushdown(p);
int mid=(t[p].l+t[p].r)>>1;
if(r<=mid)return query(ls(p),l,r);
if(l>mid) return query(rs(p),l,r);
return query(ls(p),l,r)+query(rs(p),l,r);
}
inline void modify(int p,int l,int r,int x){
if(l<=t[p].l&&t[p].r<=r)return t[p]=x;
int mid=(t[p].l+t[p].r)>>1;
pushdown(p);
if(l<=mid)modify(ls(p),l,r,x);
if(r>mid) modify(rs(p),l,r,x);
pushup(p);
}
}
void solve(){
fr(n),fr(m),fr(p);
for(int i=1;i<=n;i++)fr(a[i]);
seg::build(1,1,n);
while(m-->0){
int op,l,r;fr(op),fr(l),fr(r);
if(op==1){
int x;fr(x);
seg::modify(1,l,r,x);
}
else{
auto res=seg::query(1,l,r);
fw(res.size()),pc(' ');
for(auto i:res)fw(i.second),pc(' ');
pc('\n');
}
}
}
int main(){
int Count=1;//fr(Count);
while(Count--)solve();
}
/*
多测不清空,OI见祖宗。
multitesting without clearing,oier meets the LCA.
十年OI一场空,不开LL见祖宗。
Ten years of OI just AFO,no #define int long long sees the LCA.
似是神犇成才处,实为蒟蒻黄泉路。
It is likely to be the Au medal for the big old,but in fact it is the Si medal for me.
黄题有恨无正解,码力不若小学生。
A yellow problem I can't AC,codeforces is not as NB as EUlar Shai.
今生无奈入OI,来世不做信竞人。
This life I am a Silly Being in oi,next life I won't f**k the sh*t of infomatics.
*/