当前位置: 首页 > news >正文

AT_arc206_a [ARC206A] Range Replace

显然对于同色连续段只用考虑最右边的一个,因为能拓展的都一样。

按照同色段缩起来后,考虑一个段能拓展多少种序列,思考一下容易发现是 \(\sum_{j>i} [col_j\ne col_i]\)

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define fr(x) fin(x),fout(x);
#define Fr(x,y) fin(x),fout(y)
#define INPUT(_1,_2,FILE,...) FILE
#define IO(...) INPUT(__VA_ARGS__,Fr,fr)(__VA_ARGS__)
using namespace std;
using namespace __gnu_pbds;
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define cfast ios::sync_with_stdio(false);cin.tie(0),cout.tie(0)
#define ll long long
#define ull unsigned long long
#define intz(x,y) memset((x),(y),sizeof((x)))
char *p1,*p2,buf[100000];
#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
#define tup(x) array<int,(x)>
inline ll read(){ll x=0,f=1;char ch=nc();while(ch<48||ch>57){if(ch=='-')f=-1;ch=nc();}while(ch>=48&&ch<=57)x=x*10+ch-48,ch=nc();return x*f;
}
//void write(int x){cout<<x<<' ';}
//void write(pii x){cout<<"P("<<x.fi<<','<<x.se<<")\n";}
//void write(vector<auto>x){for(auto i:x)write(i);cout<<'\n';}
//void write(auto *a,int l,int r){for(int i=l;i<=r;i++)write(a[i]);cout<<'\n';}
inline ll lowbit(ll x){return x&-x;}
#define pcount(x) __builtin_popcount(x)
inline void cmx(ll &x,ll y){if(y>x)x=y;}
inline void cmn(ll &x,ll y){if(y<x)x=y;}
const int mod=998244353;
ll qp(ll x,int y){ll res=1;for(;y;x=x*x%mod,y>>=1)if(y&1)res=res*x%mod;return res;}
const int N=1e6+5;
#define int ll
int a[N],cnt[N];
inline void UesugiErii(){int n,c=0,ans=0;cin>>n;for(int i=1;i<=n;i++)cin>>a[i];for(int i=1;i<=n;i++){int t=i;for(;t<n&&a[t+1]==a[i];++t);ans+=(t-i+1)*(c-cnt[a[i]]),++c,i=t,++cnt[a[i]];}cout<<ans+1;
}
signed main(){//IO();//cfast;int _=1;//cin>>_;for(;_;_--)UesugiErii();return 0;
}
http://www.zskr.cn/news/70672.html

相关文章:

  • 2025下半年徐州虹吸管厂商综合评测与选购指南
  • 2025年7款免费AI写论文工具推荐:毕业论文一键生成神器!
  • 2025年靠谱的木桩厂家最新推荐排行榜
  • 2025年热门的防汛木桩热门厂家推荐榜单
  • 妇科炎症口服药品牌排名及口碑解析
  • 妇科炎症吃什么药?科学认知与规范应对指南
  • 2025年知名的AI矩阵系统实力推荐榜
  • 上涨预测202512040722
  • 2025年12月江苏地区变压器制造厂综合推荐指南
  • 2025年12月江苏箱变企业推荐前五优质供应商指南
  • 2025年12月江苏箱变企业推荐前十名盘点
  • 2025年下半年徐州喷灌机管厂商选购指南:十大口碑推荐品牌解析
  • 2025高速机厂家哪家好?激光切割设备厂家推荐
  • 2025不锈钢阀门管件工厂推荐综合榜单
  • Bitchat for Android:安全、去中心化的蓝牙网状网络即时通讯应用
  • 2025杭州单位保洁哪家强?这份杭州单位保洁公司推荐清单合集
  • 2025下半年徐州MPP电力管优质厂商综合推荐指南
  • 2025年下半年内蒙古探水钻机企业综合评测与选购指南
  • 2025年下半年内蒙古探水钻机企业综合推荐指南:十大优质供应商盘点
  • 杭州拱墅区初中初一初二初三中考辅导机构推荐——德易辅导班李秋老师
  • 2025年下半年内蒙古履带钻机品牌综合推荐与选购指南
  • RSI 2
  • RSI 1
  • MediatR 中介者模式
  • FluentValidation 模型校验框架
  • IdentityServer4认证授权之OpenId Connect认证流程
  • IdentityServer4认证授权之OpenId Connect方案
  • IdentityServer4认证授权之隐式流模式(Implicit)
  • .NET Core 微服务之RabbitMQ分布式链路追踪
  • M726芯片