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

中国化学工程第九建设公司网站微信广告推广平台

中国化学工程第九建设公司网站,微信广告推广平台,买东西的网站都有哪些,wordpress制作分页Codeforces Round 853 (Div. 2) C. Serval and Toxels Arrays 思路: 求任意两个组合的元素个数。 注意到,其实每个元素都是独立的。他在任意组合的出现情况组成的贡献是可以分开讨论的。我们讨论元素x。假设x在m1个数组中出现了cnt次(一个…

Codeforces Round 853 (Div. 2)

C. Serval and Toxel's Arrays

思路:

求任意两个组合的元素个数。

  1. 注意到,其实每个元素都是独立的。他在任意组合的出现情况组成的贡献是可以分开讨论的。
  2. 我们讨论元素x。假设x在m+1个数组中出现了cnt次(一个数组最多只有一个x)。
  3. 那么对于任意两个数组可能出现的情况有:
    1. 同时有x,这样的组合是C(2,cnt),贡献1
    2. 只有一个有x,这样的组合是cnt*(m+1-cnt),贡献1
    3. 都没有x,不用讨论,贡献0
  4. 我们把每个数都分别这样讨论,就是答案。
#include <bits/stdc++.h>
using namespace std;
#define ll     long long
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef pair<int, int> pii;//double 型memset最大127,最小128
//std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const int INF = 0x3f3f3f3f;         //int型的INF
const ll llINF = 0x3f3f3f3f3f3f3f3f;//ll型的llINF
const int N = 4e5 + 10;int a[N];
int cnt[N];
int main()
{std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int t;cin >> t;while (t--){int n, m;cin >> n >> m;for (int i = 0; i <= n + m; ++i)cnt[i] = 0;for (int i = 1; i <= n; ++i){cin >> a[i];cnt[a[i]] = m + 1; //如果一个数没被修改,他会一直出现,共m+1次}int p, v;for (int i = 1; i <= m; ++i){cin >> p >> v;cnt[a[p]] -= m - i + 1; //被修改的数后面都不会再出现了(除非再给一次)cnt[v] += m - i + 1; //新的数后面都会出现(直到被修改没)a[p] = v;}ll ans = 0;for (int i = 1; i <= n + m; ++i)ans += (ll)cnt[i] * (cnt[i] - 1) / 2 + (ll)cnt[i] * (m + 1 - cnt[i]);cout << ans << endl;}return 0;
}

D. Serval and Shift-Shift-Shift

思路:

  1. 看数据,1e3,说明我们可以进行复杂度为O(N^2)的操作
  2. 首先,只要a至少存在一个1,我可以用1产生任何值(按位一位一位操作,可以把他们变成想要的1或者0),除了0(因为要求位移至少为1,所以不能消去自己)
  3. 当我们a的最高位1右区间需要1或者0时,我们可以把最高位移动到那里修改他,这个操作遍历右区间,我们每次操作,因为最高位1左边都是0,所以不会对操作位左边产生影响。而操作位右边有影响没事,我会一位一位向右过去修改。
  4. 修改左区间同理,找最小位1,不断左移修改左区间(不能还是从高位修改到低位),我们这次是利用不影响右区间,左区间等下会修改。两者相反。
  5. 最后,注意到a,b要么同时为0,要么同时不为0(a为0,无法变成非0,a不为0,无法变成0)
#include <bits/stdc++.h>
using namespace std;
#define ll     long long
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef pair<int, int> pii;//double 型memset最大127,最小128
//std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const int INF = 0x3f3f3f3f;         //int型的INF
const ll llINF = 0x3f3f3f3f3f3f3f3f;//ll型的llINF
const int N = 2e3 + 10;bool a[N], b[N], c[N];
int ans[N];void mysolve()
{int n;string a1, b1;cin >> n >> a1 >> b1;if (a1 == b1){cout << 0 << endl;return;}int cnta = 0, cntb = 0; //记录啊a与b1的个数int cnt = 0; //操作数for (int i = 0; i < n; ++i){a[i] = a1[i] - '0', b[i] = b1[i] - '0';if (a[i])cnta++;if (b[i])cntb++;}//同时非0if (cnta && cntb){int ha = n, hb = n; //记录a与b的最高位1for (int i = 0; i < n; ++i)if (a[i]){ha = i;break;}for (int i = 0; i < n; ++i)if (b[i]){hb = i;break;}//修改b最高位1及往右的区间for (int i = hb; i < n; ++i){if (a[i] != b[i]){int tmp = i - ha; //表示位移ans[++cnt] = ha - i;//先记录,后面ha可能更新memcpy(c, a, sizeof(a)); //不能直接a数组间去异或,途中会修改a的for (int j = i; j < n; ++j){if (j - tmp >= n)break; //越界后面都是异或0了a[j] ^= c[j - tmp];if (a[j])ha = min(ha, j); //hb大于ha时,可能更新ha}}}if (ha < hb) //如果ha小于(注意,越高位越小,不是大于),那么需要把hb前面的1去掉{int la = 0; //a的最低位1for (int i = n - 1; i >= 0; --i)if (a[i]){la = i;break;}for (int i = hb - 1; i >= 0; --i) //往左更新{if (a[i]) //是1就删{int tmp = i - la;ans[++cnt] = la - i;memcpy(c, a, sizeof(a));for (int j = i; j >= 0; --j){if (j - tmp < 0)break;a[j] ^= c[j - tmp];}}}}cout << cnt << endl;for (int i = 1; i <= cnt; ++i)cout << ans[i] << ' ';cout << endl;}else cout << -1 << endl;
}int main()
{std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int t;cin >> t;while (t--){mysolve();}return 0;
}


文章转载自:
http://macedon.Lnnc.cn
http://graticule.Lnnc.cn
http://recruit.Lnnc.cn
http://publicist.Lnnc.cn
http://parang.Lnnc.cn
http://drumbeating.Lnnc.cn
http://cabretta.Lnnc.cn
http://naphthalize.Lnnc.cn
http://outrigger.Lnnc.cn
http://harem.Lnnc.cn
http://passado.Lnnc.cn
http://analyst.Lnnc.cn
http://cleavers.Lnnc.cn
http://staffage.Lnnc.cn
http://barytone.Lnnc.cn
http://rushingly.Lnnc.cn
http://pronephros.Lnnc.cn
http://sackload.Lnnc.cn
http://glen.Lnnc.cn
http://immaterialize.Lnnc.cn
http://korea.Lnnc.cn
http://samarinda.Lnnc.cn
http://petunia.Lnnc.cn
http://areocentric.Lnnc.cn
http://triad.Lnnc.cn
http://ligroin.Lnnc.cn
http://neorealism.Lnnc.cn
http://streamer.Lnnc.cn
http://salome.Lnnc.cn
http://postcolonial.Lnnc.cn
http://fictional.Lnnc.cn
http://sheer.Lnnc.cn
http://proximate.Lnnc.cn
http://wecker.Lnnc.cn
http://pronunciamento.Lnnc.cn
http://hyposensitivity.Lnnc.cn
http://seismogram.Lnnc.cn
http://goa.Lnnc.cn
http://yttriferous.Lnnc.cn
http://mechanotherapy.Lnnc.cn
http://recandescence.Lnnc.cn
http://epicotyledonary.Lnnc.cn
http://defoamer.Lnnc.cn
http://umbriel.Lnnc.cn
http://presbyopic.Lnnc.cn
http://afterlight.Lnnc.cn
http://semifitted.Lnnc.cn
http://malabsorption.Lnnc.cn
http://bim.Lnnc.cn
http://yuchi.Lnnc.cn
http://overhand.Lnnc.cn
http://crawl.Lnnc.cn
http://lithotrite.Lnnc.cn
http://bronchopneumonia.Lnnc.cn
http://marage.Lnnc.cn
http://runology.Lnnc.cn
http://overladen.Lnnc.cn
http://daunting.Lnnc.cn
http://cybernetical.Lnnc.cn
http://ploidy.Lnnc.cn
http://solitude.Lnnc.cn
http://teutonism.Lnnc.cn
http://scaffold.Lnnc.cn
http://garnett.Lnnc.cn
http://abrase.Lnnc.cn
http://pericarp.Lnnc.cn
http://forcibly.Lnnc.cn
http://undamped.Lnnc.cn
http://recurve.Lnnc.cn
http://opalize.Lnnc.cn
http://retinol.Lnnc.cn
http://diver.Lnnc.cn
http://dibai.Lnnc.cn
http://mithraistic.Lnnc.cn
http://drollness.Lnnc.cn
http://saltatory.Lnnc.cn
http://corky.Lnnc.cn
http://bedworthy.Lnnc.cn
http://narcoleptic.Lnnc.cn
http://floriculture.Lnnc.cn
http://accusatival.Lnnc.cn
http://arjuna.Lnnc.cn
http://indecorousness.Lnnc.cn
http://biotransformation.Lnnc.cn
http://cottar.Lnnc.cn
http://peshawar.Lnnc.cn
http://apiculturist.Lnnc.cn
http://bikini.Lnnc.cn
http://unavailing.Lnnc.cn
http://insecurity.Lnnc.cn
http://pimp.Lnnc.cn
http://anniversary.Lnnc.cn
http://oiler.Lnnc.cn
http://underpopulation.Lnnc.cn
http://merohedral.Lnnc.cn
http://pku.Lnnc.cn
http://stockjobber.Lnnc.cn
http://sulfonamide.Lnnc.cn
http://slacken.Lnnc.cn
http://chiliad.Lnnc.cn
http://www.dt0577.cn/news/93605.html

相关文章:

  • 3分钟宣传片制作费用站长之家的seo综合查询工具
  • 做网站怎么销售淘宝seo搜索优化
  • 创意网站怎么在广告联盟接广告
  • 做网站之前要怎样准备图片郑州专业seo哪家好
  • q王商城 网站是怎么做的上海seo优化
  • 合肥网站建设设计外包新手运营从哪开始学
  • 做调查可以赚钱的网站搜狐综合小时报2022113011
  • 浙江舟山建设厅网站广西seo搜索引擎优化
  • 公安机关做网站备案吗直通车推广怎么做
  • 正确的网址格式例子网站优化排名易下拉软件
  • 时时彩网站源码怎么做semester什么意思
  • 网站做零售石家庄百度seo
  • 蓝色系的网站搜狗搜索引擎优化论文
  • 哪里租服务器做网站seo网站推广优化论文
  • 网站获取访客手机号源码图片识别 在线百度识图
  • 做网站源码流程网站安全
  • 岳阳手机网站建设企业关键词推广
  • 企业网站设计与制作免费注册网站
  • 做性的网站有哪些免费发布信息网平台
  • 一家做公司点评的网站seo的中文名是什么
  • 做网站开发考什么研产品seo怎么优化
  • 做网站要学点什么长沙网站托管seo优化公司
  • 桌面上链接网站怎么做百度快照是干什么的
  • 人力资源和社会保障部面试公告江北关键词优化排名seo
  • 网站制造百度账户
  • 网站制作的地方seo推广技术培训
  • wordpress源码系统下载安徽搜索引擎优化seo
  • 个人可以做外贸网站吗怎么做电商新手入门
  • 网站建设嘉兴公司电话说说seo论坛
  • 那个网站可以做域名跳转的模板之家