Problem Codeforces Round #539 (Div. 2) - D. Sasha and One More Name Time Limit: 1000 mSec Problem Description Input The first line contains one string s (1≤|s|≤5000) — the initial name, which consists only of lowercase Latin letters. It is guarante…
Problem Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax Time Limit: 2000 mSec Problem Description Input The first line contains one integer n (2≤n≤3⋅10^5) — the size of the array. The second line contains n integers a1,a2,…,an (0≤ai<2^…
题解看这里 liouzhou_101的博客园 更简洁的代码看这里: #include <bits/stdc++.h> using namespace std; typedef long long LL; #define X first #define Y second inline void read(int &x) { int flag = 1; char ch; while(!isdigit(ch=getchar()))if(ch=='-')flag=-flag; for(x=0;…
如果mod是质数就好做了,但是做除法的时候对于合数mod可能没有逆元.所以就只有存一下mod的每个质因数(最多9个)的幂,和剩下一坨与mod互质的一部分.然后就能做了.有点恶心. CODE #include <bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN = 100005; const int MAXP = 9; int n, q, a[MAXN], p[MAXP], cnt, mod, phi…
题解请看 Felix-Lee的CSDN博客 写的很好,不过最后不用判断最小值是不是1,因为[i,i]只有一个点,一定满足条件,最小值一定是1. CODE 写完就A,刺激. #include <bits/stdc++.h> using namespace std; typedef long long LL; #define X first #define Y second inline void read(int &x) { int flag = 1; char ch; while(!i…
E. Sasha and Array 题目连接: http://codeforces.com/contest/719/problem/E Description Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types: 1 l r x - increase all integers on the segment from l…
E. Sasha and Array time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types: 1 l r…
A:即求长度为偶数的异或和为0的区间个数,对前缀异或和用桶记录即可. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long #define N 300010 char getc(){char…
题意:给你n个点,m条边,然后让你使得这个这个图成为一个协和图,需要加几条边.协和图就是,如果两个点之间有一条边,那么左端点与这之间任意一个点之间都要有条边. 思路:通过并查集不断维护连通量的最大编号的节点,然后遍历即可. 代码: #include<bits/stdc++.h> using namespace std; #define int long long #define N 1005000 int f[N];int n,m; int getf(int v){// 并查集模板 if(v=…
Codeforces Round #539 (Div. 1) A. Sasha and a Bit of Relax description 给一个序列\(a_i\),求有多少长度为偶数的区间\([l,r]\)满足\([l,mid]\)的异或和等于\([mid+1,r]\)的异或和. solution 等价于询问有多少长度为偶数的区间异或和为\(0\). 只需要两个位置的异或前缀和与下标奇偶性相同即可组成一个合法区间. #include<cstdio> #include<algorith…
Codeforces Round #539 Div1 题解 听说这场很适合上分QwQ 然而太晚了QaQ A. Sasha and a Bit of Relax 翻译 有一个长度为\(n\)的数组,问有多少个长度为偶数的连续区间,使得其前一半的异或和等于后一半的异或和. 题解 显然就是求长度为偶数且异或和为\(0\)的区间个数 求异或和为\(0\)的区间个数很简单,对于整个区间求异或前缀和看看有多少个相等就好了. 求长度为偶数的也很简单,把每个位置的异或前缀和按照位置的奇偶性分开求个数每次计算一下…