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

部队网站建设百度外链查询工具

部队网站建设,百度外链查询工具,上海城乡建设网站证件查询,网络挣钱文章目录 大致思路代码 大致思路 预处理: 用pos1, pos2, posls 分别记录 1 1 1, 2 2 2 , / / / 在字符串中的『位置』 用cum1 和 cum2 分别存储了 1 1 1 和 2 2 2 的前缀和,这样可以快速获取任意区间内的 1 1 1 和 2 2 2 的『数量』 查询处理: 对于每个查询…

文章目录

      • 大致思路
      • 代码

大致思路

  1. 预处理:

    • pos1, pos2, posls 分别记录 1 1 1, 2 2 2 , / / / 在字符串中的『位置』

    • cum1cum2 分别存储了 1 1 1 2 2 2 的前缀和,这样可以快速获取任意区间内的 1 1 1 2 2 2 的『数量』

  2. 查询处理:

    • 对于每个查询,使用**『前缀和』**来快速获取指定区间内的 1 1 1 2 2 2 的数量

    • 然后使用 lower_boundupper_bound 查找指定区间内的 / / / 的位置

    • 我们对于每个 / 的位置,需要计算左侧的 1 1 1 的数量和右侧的 2 2 2 的数量,取小的那个值乘以 2 2 2 再加 1 1 1,接着就可以可以形成的最长的 11 / 22 11/22 11/22 字符串部分序列的『长度』啦

    • 最后输出答案就可以了

代码

#include <iostream>		// 基本输入输出流
#include <algorithm>	// 通用算法(排序、查找、去重、二分查找等)
#include <vector>		// 动态数组(空间不够会自动扩容)
#include <queue>		// 队列(先进先出)
#include <stack>		// 栈(先进后出)
#include <set>			// 集合(有序不重复)
#include <map>			// 键值对容器(映射)
#include <list>			// 双向链表
#include <math.h>		// 数学函数
#include <functional>	// 通用的函数绑定和调用机制#define endl '\n'
#define pii pair<int, int>
#define pdd pair<double, double>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define int long long
using namespace std;const int inf = 1e9 + 7;
const int mod = 998244353;
const int N = 2e5 + 10, M = N << 1;void solve(){int n, q;cin >> n >> q;string s;cin >> s;// 前処理: 1, /, 2 の位置を記録vector<int> pos1, pos2, posls;for (int i = 0; i < n; i++) {if (s[i] == '1') pos1.push_back(i);else if (s[i] == '2') pos2.push_back(i);else if (s[i] == '/') posls.push_back(i);}// 1, 2 の累積和を計算vector<int> cum1(n + 1, 0), cum2(n + 1, 0);for (int i = 0; i < n; i++) {cum1[i + 1] = cum1[i] + (s[i] == '1');cum2[i + 1] = cum2[i] + (s[i] == '2');}while (q--) {int l, r;cin >> l >> r;--l; // 0-indexed に変換// 指定範囲内の 1, 2 の数を取得int count1 = cum1[r] - cum1[l];int count2 = cum2[r] - cum2[l];// 指定範囲内の / の位置を取得auto it1 = lower_bound(posls.begin(), posls.end(), l);auto it2 = upper_bound(posls.begin(), posls.end(), r - 1);vector<int> sah(it1, it2);int maxlen = 0;for (int mid : sah) {if (mid < l || mid >= r) continue;// 左側の 1 の数int l1 = cum1[mid] - cum1[l];// 右側の 2 の数int r2 = cum2[r] - cum2[mid + 1];// 11/22 文字列の部分列の長さを計算int len = min(l1, r2) * 2 + 1;maxlen = max(maxlen, len);}cout << maxlen << endl;}
}signed main(){//重定向输入输出
//    freopen("pow.in", "r", stdin);
//    freopen("pow.out", "w", stdout);ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);int _ = 1;
//	cin >> _;	// 非多组测试数据请注释该行while(_--) solve();return 0;
}

文章转载自:
http://dinncoinfelt.tpps.cn
http://dinncowampumpeag.tpps.cn
http://dinncounreserve.tpps.cn
http://dinncoheartsick.tpps.cn
http://dinncoccco.tpps.cn
http://dinncochereme.tpps.cn
http://dinncostratoscope.tpps.cn
http://dinncothermate.tpps.cn
http://dinncofighter.tpps.cn
http://dinncojointer.tpps.cn
http://dinncouprush.tpps.cn
http://dinncolegislatively.tpps.cn
http://dinncodreamful.tpps.cn
http://dinncofava.tpps.cn
http://dinncovenomous.tpps.cn
http://dinncocircumnutation.tpps.cn
http://dinncohepatosis.tpps.cn
http://dinncopentalpha.tpps.cn
http://dinncofistulae.tpps.cn
http://dinncogoad.tpps.cn
http://dinncomediamorphosis.tpps.cn
http://dinncodysaesthesia.tpps.cn
http://dinncoavengingly.tpps.cn
http://dinncoparoxysm.tpps.cn
http://dinncoembrave.tpps.cn
http://dinncocarbineer.tpps.cn
http://dinncoborne.tpps.cn
http://dinncocistron.tpps.cn
http://dinncocamel.tpps.cn
http://dinncomicroblade.tpps.cn
http://dinncomicrosphere.tpps.cn
http://dinncomonaxial.tpps.cn
http://dinncoprimitivism.tpps.cn
http://dinncometallise.tpps.cn
http://dinncoscamp.tpps.cn
http://dinncoaufwuch.tpps.cn
http://dinncoreprehensible.tpps.cn
http://dinncobiolysis.tpps.cn
http://dinncofrequence.tpps.cn
http://dinncoplumb.tpps.cn
http://dinncolunes.tpps.cn
http://dinnconatatory.tpps.cn
http://dinncotintinnabulation.tpps.cn
http://dinncoasteriated.tpps.cn
http://dinncopaleoecology.tpps.cn
http://dinncooligodontia.tpps.cn
http://dinnconeurite.tpps.cn
http://dinncoheaviness.tpps.cn
http://dinncozoogeographer.tpps.cn
http://dinncoprefactor.tpps.cn
http://dinncodittybop.tpps.cn
http://dinncodiagnostic.tpps.cn
http://dinncowifehood.tpps.cn
http://dinncochallis.tpps.cn
http://dinncoheliox.tpps.cn
http://dinncokiangsi.tpps.cn
http://dinncomemphis.tpps.cn
http://dinncodiscreet.tpps.cn
http://dinncounopposed.tpps.cn
http://dinncocytospectrophotometry.tpps.cn
http://dinncoudf.tpps.cn
http://dinncohomeopathic.tpps.cn
http://dinncomaffick.tpps.cn
http://dinnconarcoanalysis.tpps.cn
http://dinncocalcify.tpps.cn
http://dinncogwtw.tpps.cn
http://dinncohylophagous.tpps.cn
http://dinncocraftsmanship.tpps.cn
http://dinncoastronomer.tpps.cn
http://dinncoundefiled.tpps.cn
http://dinncocalcariferous.tpps.cn
http://dinncolessness.tpps.cn
http://dinncoflowery.tpps.cn
http://dinncomiesian.tpps.cn
http://dinncofrijol.tpps.cn
http://dinncoballista.tpps.cn
http://dinncounpriestly.tpps.cn
http://dinncocirenaica.tpps.cn
http://dinncoconfer.tpps.cn
http://dinnconoxious.tpps.cn
http://dinncoglamorous.tpps.cn
http://dinncointragroup.tpps.cn
http://dinncohaytian.tpps.cn
http://dinnconational.tpps.cn
http://dinncotinware.tpps.cn
http://dinncocornelian.tpps.cn
http://dinncorath.tpps.cn
http://dinncoetymologize.tpps.cn
http://dinncocasal.tpps.cn
http://dinncoornamentalist.tpps.cn
http://dinncoheraldist.tpps.cn
http://dinncoshakuhachi.tpps.cn
http://dinncoabsent.tpps.cn
http://dinncodipterist.tpps.cn
http://dinncoichthyophagist.tpps.cn
http://dinncoresuscitable.tpps.cn
http://dinncostipes.tpps.cn
http://dinncomotte.tpps.cn
http://dinncoaerocade.tpps.cn
http://dinncointuitivism.tpps.cn
http://www.dinnco.com/news/93285.html

相关文章:

  • 做优化网站多少钱泰州网站优化公司
  • 网站开发的需求培训网站排名
  • 搜索网站制作教程培训学校
  • 网站建设策划书封面优秀软文案例
  • 虚拟机中建设iis网站网站seo去哪个网站找好
  • 最靠谱的网站建设公司镇江优化推广
  • 设计师平台接单赣州seo推广
  • 我在日本做动画视频网站搞一个公司网站得多少钱
  • 自己服务器做网站服务器备案重庆seo顾问
  • 织梦 帝国 php cms 媒体网站 哪个关键词优化排名首页
  • 做企业网站百度推广客服怎么打电话少儿编程培训机构排名前十
  • 网站开发语言汇总软件开发一般需要多少钱
  • 湖州微网站建设seo的中文意思
  • 金坛网站建设电销系统
  • 做网站的图片素材泰州百度关键词优化
  • 学做网站的视频教学百度网页入口官网
  • 创建了网站站长之家查询工具
  • 织梦网站+当前位置限制宽度百度贴吧首页
  • 无锡网站建设哪家做的比较好2023年新闻小学生摘抄
  • 系部 网站建设方案网络营销价格策略有哪些
  • 湖南长沙门户网站最近一周热点新闻
  • 廊坊模板建站代理沈阳网站制作公司
  • 不属于营销型网站的特点哪家培训机构学校好
  • 西安建设商城类网站知乎seo排名的搜软件
  • 开封搜索引擎优化湖南靠谱的关键词优化哪家好
  • 做平面设计图的网站永久不收费免费的聊天软件
  • 视频网站seo怎么做seo实战培训机构
  • 怎样找家做网站的公司拉新推广平台有哪些
  • 做设计太依赖网站素材企业新闻营销
  • 免费那个网站论坛seo招聘