CF Round #687 Div2 简要题解】的更多相关文章

题面 A 可以发现,最远的几个人一定是 \((1, 1), (1, m), (n, 1), (n, m)\) 中的一个,直接计算即可. B 注意到颜色数量很少,直接暴力枚举最终的颜色后模拟即可. C 本质上删除第一个位置就是将初始的 \(p + 1\),于是可以考虑直接枚举会将初始位置往后挪几位,需要的操作一次数就是 \(p\) 之后模 \(k\) 与 \(p\) 同余的位置中 \(0\) 的数量. 直接记录一个模意义下的前缀和,再在枚举 \(p\) 初始位置时维护另一个模意义下的前缀和即可.…
Contest link A.Specific Tastes of Andre Problem link 题意 构造一个长度为 \(n\) 的序列,使得每个非空子序列的和都被其长度整除. 思路 直接每个数都是 \(1\) 即可. 代码 int main() { int T; scanf( "%d",&T ); while ( T-- ) { int n=read(); for ( int i=1; i<=n; i++ ) printf( "1 " );…
CF Round #580(div2)题解报告 T1 T2 水题,不管 T3 构造题,证明大约感性理解一下 我们想既然存在解 \(|a[n + i] - a[i]| = 1\) 这是必须要满足的 既然这样,那么图必须是这样的 \(-\),是相邻的两个数中的较小的一个,\(+\)是相邻的两个数中较大的 这样分配是肯定有解的 但是当n时偶数的时候,手玩一下就会发现,不可能满足+-交替,所以无解 #include<cstdio> #include<iostream> #include&l…
CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言,A名次在最末,求A最好名次和最坏名字. 分析: 我们先考虑最坏怎么来 最劣的时候就是尽可能多的人总分与A相同 那么对于和为x+y的有序数对组合有x+y-1个,除去自己就是x+y-2个,而第一名位置是1,所以最劣位置是x+y-1,取min(x+y-1,n)即使最劣位置 而对于最优位置,x+y<=n,…
打这场的时候迷迷糊糊的,然后掉分了( A Prison Break: 题面很复杂,但是题意很简单,仅需求出从这个点到四个角的最大的曼哈顿距离即可 #include <bits/stdc++.h> using namespace std; typedef long long ll; int times; int n,m,r,c; int main() { ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); cin >> times…
A. Alyona and Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of inte…
题目链接:C. DNA Alignment 题目大意就不写了,因为叙述会比较麻烦..还是直接看英文题面吧. 题目分析 经过观察与思考,可以发现,构造的串 T 的每一个字符都与给定串 S 的每一个字符匹配了 L 次,那么 令 S 中 A,C,G,T 的数量分别为 A1, B1, C1, D1, T 中 A,C,G,T 的数量分别为 A2, B2, C2, D2. p(S, T) = L * (A1A2 + B1B2 + C1C2 + D1D2) 也就是说,T中的一个字符A,可以对p(S, T)产生…
题目链接:E. A and B and Lecture Rooms 题目大意 给定一颗节点数10^5的树,有10^5个询问,每次询问树上到xi, yi这两个点距离相等的点有多少个. 题目分析 若 x==y 直接返回 n. 先求出 x, y 两个点的中点. 先求出 LCA(x, y) = z,假设 Depth[x] >= Depth[y] ,若Depth[x] == Depth[y] ,那么 z 就是它们的中点. 答案就是,n - Size[fx] - Size[fy],fx 是从x向上跳,一直跳…
题目链接:D. A and B and Interesting Substrings 题目大意 给定26个小写字母的权值,一共26个整数(有正有负). 给定一个小写字母组成的字符串(长度10^5),求有多少长度大于1的子串满足: 1)首尾字符相同. 2)除了首尾字符外,其他字符的权值和为0. 题目分析 使用STL Map.开26个Map,给每个字母开一个. 先求出权值的前缀和 Sum[] . 然后1到l枚举每一位字符,如果是a,那么 Ans += Map[a][Sum[i - 1]]; 然后 +…
A. Grasshopper And the String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became i…