#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100005
struct node
{
int l;
int r;
int color;
}t[MAXN*3];
bool r[50];
void make(int st,int ed,int i)
{
t[i].l=st;
t[i].r=ed;
t[i].color=1;
if(st==ed)
{
return ;
}
int mid=(t[i].l+t[i].r)/2;
make(st,mid,i*2);
make(mid+1,ed,i*2+1);
}
void updata(int st,int ed,int i,int c)
{
if(st==t[i].l&&ed==t[i].r)
{
t[i].color=c;
return ;
}
if(t[i].color>0)
{
t[i*2+1].color=t[i*2].color=t[i].color;
t[i].color=0;
}
int mid=(t[i].l+t[i].r)/2;
if(st>mid)
updata(st,ed,i*2+1,c);
else if(ed<=mid)
updata(st,ed,i*2,c);
else
{
updata(st,mid,i*2,c);
updata(mid+1,ed,i*2+1,c);
}
}
void query(int st,int ed,int i)
{
if(t[i].color>0)
{
r[t[i].color]=1;
return ;
}
int mid=(t[i].l+t[i].r)/2;
if(st>mid)
query(st,ed
Count Color
最新推荐文章于 2023-06-21 14:24:43 发布
这篇博客主要介绍了如何利用C语言进行颜色计数查询。通过struct结构体来组织数据,实现了高效的颜色统计方法。

最低0.47元/天 解锁文章
817

被折叠的 条评论
为什么被折叠?



