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

wordpress采集vip视频seo顾问收费

wordpress采集vip视频,seo顾问收费,it外包服务哪家好,做网站需要哪方面的编程题意 传送门 AtCoder 265G 012 Inversion 题解 直接维护逆序对数量比较困难&#xff0c;考虑到元素值域很小&#xff0c;直接将不同数值对解耦进行维护。具体而言&#xff0c;线段树维护区间 0 , 1 , 2 0,1,2 0,1,2 的数量&#xff0c;以及满足 i < j i<j i<j 时…
题意

传送门 AtCoder 265G 012 Inversion

题解

直接维护逆序对数量比较困难,考虑到元素值域很小,直接将不同数值对解耦进行维护。具体而言,线段树维护区间 0 , 1 , 2 0,1,2 0,1,2 的数量,以及满足 i < j i<j i<j a [ i ] = x , a [ j ] = 1 a[i]=x,a[j]=1 a[i]=x,a[j]=1 的数对数量 n u m [ x ] [ y ] num[x][y] num[x][y]。总时间复杂度 O ( d 2 n log ⁡ n ) O(d^2n\log n) O(d2nlogn),其中, d d d 是数组取值的规模。

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct ST {struct LzNode {vector<int> p;LzNode() : p(3) {reset();}void reset() {iota(p.begin(), p.end(), 0);}void update(vector<int> &f) {vector<int> tmp(3);for (int i = 0; i < 3; ++i) {tmp[i] = f[p[i]];}swap(tmp, p);}};struct Node {vector<int> cnt;vector<vector<ll>> num;Node() : cnt(3), num(3, vector<ll>(3)) {}Node operator+(const Node &o) {Node res;for (int i = 0; i < 3; ++i) {res.cnt[i] = cnt[i] + o.cnt[i];}for (int i = 0; i < 3; ++i) {for (int j = 0; j < 3; ++j) {res.num[i][j] = num[i][j] + o.num[i][j];}}for (int i = 0; i < 3; ++i) {for (int j = 0; j < 3; ++j) {res.num[i][j] += (ll)cnt[i] * o.cnt[j];}}return res;}void update(vector<int> &p) {Node res;for (int i = 0; i < 3; ++i) {res.cnt[p[i]] += cnt[i];}for (int i = 0; i < 3; ++i) {for (int j = 0; j < 3; ++j) {res.num[p[i]][p[j]] += num[i][j];}}swap(*this, res);}};vector<Node> dat;vector<LzNode> lz;ST(vector<int> &a) {int n = a.size();int k = 1;while (k < n) {k *= 2;}k *= 2;dat = vector<Node>(k);lz = vector<LzNode>(k);function<void(int, int, int)> init = [&](int p, int l, int r) {if (r - l == 1) {dat[p].cnt[a[l]] += 1;return;}int m = (l + r) / 2;int chl = p * 2 + 1, chr = p * 2 + 2;init(chl, l, m);init(chr, m, r);dat[p] = dat[chl] + dat[chr];};init(0, 0, n);}void pushdown(int p, int l, int r) {int chl = p * 2 + 1, chr = p * 2 + 2;auto &f = lz[p].p;lz[chl].update(f);lz[chr].update(f);dat[chl].update(f);dat[chr].update(f);lz[p].reset();}void change(int a, int b, vector<int> &f, int p, int l, int r) {if (r <= a || b <= l) {return;}if (a <= l && r <= b) {lz[p].update(f);dat[p].update(f);return;}int m = (l + r) / 2;int chl = p * 2 + 1, chr = p * 2 + 2;pushdown(p, l, r);change(a, b, f, chl, l, m);change(a, b, f, chr, m, r);dat[p] = dat[chl] + dat[chr];}Node query(int a, int b, int p, int l, int r) {if (r <= a || b <= l) {return Node();}if (a <= l && r <= b) {return dat[p];}int m = (l + r) / 2;int chl = p * 2 + 1, chr = p * 2 + 2;pushdown(p, l, r);return query(a, b, chl, l, m) + query(a, b, chr, m, r);}
};
int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int n, q;cin >> n >> q;vector<int> a(n);for (int i = 0; i < n; ++i) {cin >> a[i];}ST tr(a);while (q--) {int op;cin >> op;if (op == 1) {int l, r;cin >> l >> r;l -= 1;auto nd = tr.query(l, r, 0, 0, n);ll res = 0;for (int i = 0; i < 3; ++i) {for (int j = 0; j < i; ++j) {res += nd.num[i][j];}}cout << res << '\n';} else {int l, r;vector<int> b(3);cin >> l >> r;l -= 1;for (int i = 0; i < 3; ++i) {cin >> b[i];}tr.change(l, r, b, 0, 0, n);}}return 0;
}
http://www.hkea.cn/news/901691/

相关文章:

  • 做网站毕设任务书网络营销网站建设案例
  • .net 企业网站 模版关键词seo深圳
  • 网站建设优化价格网站seo诊断
  • 网站设计详细设计有没有好用的网站推荐
  • 没有货源可以开网店吗网站更新seo
  • 淄博有做网站的吗百度搜索排名怎么收费
  • wordpress页面添加自定义字段木卢seo教程
  • 长寿网站制作保定seo排名外包
  • 域名和网站一样吗电商运营推广怎么做
  • css个人简介网站怎么做b2b网站免费推广平台
  • 网站建设中企动力上海百度广告投诉电话客服24小时
  • 深圳靠谱的电商公司正版搜索引擎优化
  • 自己如何做团购网站腾讯云建站
  • 怀化招标网站磁力狗bt
  • 佛山网站建设服务公司培训机构查询网
  • 海尔集团电商网站建设考证培训机构
  • 动漫制作专业的高职实训室福州整站优化
  • 织梦商城网站模板免费下载怎么在网上做推广
  • asp做网站用什么写脚本温岭网络推广
  • 怎么建设外贸网站免费发seo外链平台
  • 郴州是几线城市武汉网站seo推广公司
  • 网站开发工程师求职信焊工培训内容
  • 铜陵公司做网站中国网站排名100
  • 我要建一个网站泰州百度公司代理商
  • php响应式网站模板vi设计公司
  • 随身wifi网站设置广告投放是做什么的
  • 中企动力做网站的优势网络销售平台有哪些软件
  • 网站建设的费用如何查看百度搜索指数
  • 自己做网站需要什么seo的基本步骤
  • 视频直播app开发网站南京最新消息今天