P1558 RE求条
  • 板块灌水区
  • 楼主Chtholly__Nota
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/11/28 14:47
  • 上次更新2024/11/28 17:09:51
查看原帖
P1558 RE求条
847559
Chtholly__Nota楼主2024/11/28 14:47

不知道为什么就RE了

#include<bits/stdc++.h>
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/id_queue.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็
*/
#define pn putchar('\n')
#define ps putchar(' ')
using namespace std;
typedef long long ll;

template <typename T> void re(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t=((t<<3)+(t<<1)))+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}

inline void wr(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) wr(x/10);
    putchar(x%10+'0');
}

struct node{
    int l,r;
    mutable int v;
    friend bool operator < (node x,node y){
        return x.l<y.l;
    }
};

set<node> s;

auto split(int x){
    auto it=s.lower_bound({x,0,0});
    if(it!=s.end() && it->l==x) return it;
    it--;
    auto ll=it->l,rr=it->r,vv=it->v;
    s.erase(it);
    s.insert({ll,x-1,vv});
    return s.insert({x,rr,vv}).first;
}

void assign(int l,int r,int v){
    auto itr=split(r+1),itl=split(l);
    s.erase(itl,itr);
    s.insert({l,r,v});
}

int zy;

int bi(int x){
    int ret=0;
    while(x){
        if(x&1) ret++;
        x>>=1;
    }
    return ret;
}

int ask(int l,int r){
    auto itr=split(r+1),itl=split(l);
    for(auto it=itl;it!=itr;it++){
        zy|=(1<<(it->v));
    }
    return bi(zy);
}

int l,t,o,a,b,c;

char opt;

int main(){
//    freopen("P1558_1.in","r",stdin);
//    freopen("P1558.out","w",stdout);
    re(l),re(t),re(o);
    s.insert({1,l+1,1});
    for(int i=1;i<=o;i++){
        scanf("%c",&opt);
        if(opt=='C'){
            re(a),re(b),re(c);
            if(a>b) swap(a,b);
            assign(a,b,c);
        }
        else{
            zy=0;
            re(a),re(b);
            if(a>b) swap(a,b);
            wr(ask(a,b)),pn;
        }
    }
    return 0;
}



















//ด้้้้้็้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็็็็้้้้้็็็็็้้้้้้็็
2024/11/28 14:47
加载中...