#pragma GCC optimize("Ofast") #pragma GCC target ("avx") #include using namespace::std; //struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout< // #include // #include // #include // #include // #include // #include // #include // #include // using boost::math::tools::brent_find_minima; // #include // #include // namespace mp = boost::multiprecision; // typedef mp::number> cdouble; // typedef mp::cpp_int cint; // #include #include #include #include #include templateusing pbds=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>; templateusing pbds_map=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>; templateusing pqueue =__gnu_pbds::priority_queue,__gnu_pbds::rc_binomial_heap_tag>; typedef long long lint; typedef long long ll; typedef long double ldouble; typedef vector vec; typedef vector> mat; typedef vector>> mat3; typedef vector dvec; typedef vector> dmat; typedef vector>> dmat3; typedef vector svec; typedef vector> smat; typedef vector>> smat3; templateusing Vec=vector; templateusing Mat=vector>; templateusing Mat3=vector>>; templateusing Mat4=vector>>>; templateusing pvec=vector>; templateusing pmat=vector>>; templateusing pmat3=vector>>>; templateusing pmat4=vector>>>>; templateusing tvec=vector>; templateusing tmat=vector>>; templateusing tmat3=vector>>>; templateusing tmat4=vector>>>>; #define rep(i, n) for(lint i = 0; i < (lint)(n); i++) #define irep(i) for(lint i = 0;; i++) #define irep1(i) for(lint i = 1;; i++) #define irep2(i) for(lint i = 2;; i++) #define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--) #define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--) #define repi(i,a,b) for(lint i=lint(a);ilint(b);i+=c) #define all(x) (x).begin(),(x).end() #define PI 3.141592653589793 #define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5)) //#define input(a,n) lint n;cin>>n;vectora(n);rep(i,n)cin>>a[i]; #define SUM(v) accumulate(all(v),0LL) #define INF (1LL<<60) #define IINF (1<<30) #define EPS (1e-10) #define LINF 9223372036854775807 //#define MOD 998244353LL #define MOD 1000000007LL #define endl "\n" templateinline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<inline void numout2(T t){for(auto i:t)numout(i);} templateinline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<inline void output2(T t){for(auto i:t)output(i);} templateinline void _output(T t){bool f=0;for(int i=0;iinline void _output2(T t){for(int i=0;iT in(){return *istream_iterator(cin);} templateinline T gcd(T a,T b){return b?gcd(b,a%b):a;} templateinline T lcm(T a,T b){return a/gcd(a,b)*b;} templateinline T minq(T a,T b){return min(a,b);} templateinline T maxq(T a,T b){return max(a,b);} inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;} inline bool chmax(auto& s,const auto& t){bool res=s dx={-1,1,0,0,1,1,-1,-1}; const vector dy={0,0,-1,1,1,-1,1,-1}; templateclass LSEG{ lint n=1; vector node; vector lazy; T et; E ee; public: LSEG(int size,T et,E ee):et(et),ee(ee){ while(n struct segment{ private: T et; E ee; lint n; lint size; struct node{ T val; E lazy; node *lch,*rch; node(segment &seg):lch(nullptr),rch(nullptr){val=seg.et;lazy=seg.ee;} }; node* root; public: segment(int size,T et,E ee):et(et),ee(ee),n(1),size(size){ while(nval; //全部区間内 if(a<=l&&r<=b){ t->lazy=g(t->lazy,x); eval(t,r-l,k); return h(t->val,t->lazy,r-l); } //一部区間内 if(!t->lch)t->lch=new node(*this); if(!t->rch)t->rch=new node(*this); return t->val=f(update(a,b,x,2*k+1,l,(l+r)/2,t->lch),update(a,b,x,2*k+2,(l+r)/2,r,t->rch)); } //0-indexed [a,b) T get(const int& a,const int& b,const int& k,const int& l,const int& r,node* t){ eval(t,r-l,k); //区間外 if(r<=a||b<=l)return et; //全部区間内 if(a<=l&&r<=b)return t->val; //一部区間内 if(!t->lch)t->lch=new node(*this); if(!t->rch)t->rch=new node(*this); return f(get(a,b,2*k+1,l,(l+r)/2,t->lch),get(a,b,2*k+2,(l+r)/2,r,t->rch)); } inline void eval(node* t,const int& len,const int& k){ if(t->lazy==ee) return; if(k*2+1lch==nullptr)t->lch=new node(*this); if(t->rch==nullptr)t->rch=new node(*this); t->lch->lazy=g(t->lch->lazy,t->lazy); t->rch->lazy=g(t->rch->lazy,t->lazy); } t->val=h(t->val,t->lazy,len); t->lazy=ee; } T f(T a,T b){ return a; } T h(T a,E b,lint len){ return update(a,b); } E g(E a,E b){ return update(a,b); } auto update(auto a,auto b){return b==ee?a:b;} }; template class dual_segment{ struct node; using np=node*; using lint=long long; struct node{ T val; np ch[2]={nullptr,nullptr}; node(T val):val(val){} }; np root=nullptr; lint n=1,sz; T e; functionf; public: dual_segment(lint sz,T e,functionf):sz(sz),e(e),f(f){while(nval==e)return; if(!t->ch[0])t->ch[0]=new node(e); if(!t->ch[1])t->ch[1]=new node(e); t->ch[0]->val=f(t->ch[0]->val,t->val); t->ch[1]->val=f(t->ch[1]->val,t->val); t->val=e; } void set(lint a,lint b,T x,lint l,lint r,np& t){ if(!t)t=new node(e); if(r-l>1)eval(t); if(r<=a||b<=l)return; else if(a<=l&&r<=b)t->val=f(t->val,x); else if(r-l>1){ set(a,b,x,l,(l+r)/2,t->ch[0]); set(a,b,x,(l+r)/2,r,t->ch[1]); } } T get(lint x,lint l,lint r,np& t){ if(!t)t=new node(e); if(r-l>1)eval(t); if(xval; } else return f(get(x,l,(l+r)/2,t->ch[0]),get(x,(l+r)/2,r,t->ch[1])); } }; int main(){ lint n,m; cin>>n>>m; dual_segment seg(n,0,[](auto a,auto b){ return b==0?a:b; }); vec s(m),t(m); vec u(m); rep(i,m){ string x; cin>>s[i]>>t[i]>>x; if(x=="Y")u[i]=1; if(x=="K")u[i]=2; if(x=="C")u[i]=3; s[i]--; } reverse(all(s)); reverse(all(t)); reverse(all(u)); rep(i,m){ seg.set(s[i],t[i],u[i]); } lint y=0,c=0,k=0; rep(i,n){ if(seg.get(i)==1)y++; if(seg.get(i)==2)k++; if(seg.get(i)==3)c++; } cout<>n>>s; // auto seg=make_segment,lint>(n,make_pair(0LL,0LL),0LL, // [](const auto& a,const auto& b){ // return make_pair(max(a.first,b.first),min(a.second,b.second)); // }, // [](const auto& a,const auto& b){ // return a+b; // }, // [](const auto& a,const auto& b,const int& len){ // return make_pair(a.first+b,a.second+b); // }); // int cu=0; // mapc; // int judge=0; // rep(i,s.size()){ // if(s[i]=='L'){if(cu)cu--;} // else if(s[i]=='R')cu++; // else{ // if(c[cu]=='('){ // seg.update(cu,n,-1); // judge--; // } // if(c[cu]==')'){ // seg.update(cu,n,1); // judge++; // } // if(s[i]=='('){ // seg.update(cu,n,1); // judge++; // } // else if(s[i]==')'){ // seg.update(cu,n,-1); // judge--; // } // else seg.update(cu,n,0); // c[cu]=s[i]; // } // if(i)cout<<" "; // if(judge!=0||seg.get(0,n).second<0){ // cout<<-1; // }else{ // cout<