Educational Codeforces Round 48 (Rated for Div. 2)

http://codeforces.com/contest/1016

A.

没想到这个也会TLE,太粗心了

B.

暴力就好了,多情况讨论又出错...

思路跟我一样的解法  

为什么我做了那么多讨论,原因是没注意这个: 标记 最后一个字符,同时注意 l+m-3.

特殊情况就

vis 0000011111111111112

s1  abaccabaacabacabacca      红色的地方是 l 和 r ,为了防止在 l 处计数多了就得 l + m - 3

s2  abacca

  1. we[s+m-1]++;
  2. we[r-1]-we[l+m-3]

string类的find()函数总结

 string::size_type pos=0;
 while((pos=s1.find(s2,pos))!=string::npos)
   {
       vis[pos+1]=pos+1;
       pos++;
    }

KMP解法

 

原文地址:https://www.cnblogs.com/LLbinGG/p/9460065.html

时间: 2024-10-07 17:10:16

Educational Codeforces Round 48 (Rated for Div. 2)的相关文章

Educational Codeforces Round 48 (Rated for Div. 2) - 赛后补题

C. Vasya And The Mushrooms 题解:拿笔画他的行走路线,你会发现可以前缀和预处理一些东西出来. const int N = 300005; int n; ll a[N], b[N], dp[2][N], sp[2][N], sum[N]; int get_a() { dp[0][0] = 0; for (int i = 1; i < n; ++i) { dp[0][i] = dp[0][i - 1] + 1ll * i * a[i]; } int t = n; dp[1]

Educational Codeforces Round 48 (Rated for Div. 2) B Segment Occurrences

翻译 给你一个字符串\(s\)和另一个字符串\(t\),然后给你\(q\)个区间,问\(s\)在这些区间里的子串有多少个与\(t\)相同. 思路 一道要细心的模拟题,使用\(STL string\),暴力,前缀和,\(Hash\),\(Kmp\)都能做出来,然后我来介绍一下用 \(vector\)的做法. 首先预处理\(s\),从头到位找到每一个长度是字符串t的长度\(m\)的字符串,如果其与\(t\)相等,那么就往vector中压入\(1\),否则压入\(0\),这样,我们就找到每个编号的字符

Educational Codeforces Round 48 (Rated for Div. 2)G. Appropriate Team

题意:求满足条件的(i,j)对数:\(gcd(v,a_i)=x,lcm(v,a_j)=y\) 题解:\(x|a_i,a_j|y\),\(x|y\),考虑质因子p,假设a_i中p次数为a,x中次数为b,y为c,\(a_j\)为d;a>=b,c>=d. 假设a>b,c>d,那么由于\(gcd(v,a_i)=x\),v中p的次数为b,由于\(lcm(v,a_j)=y\),那么\(max(b,d)==c\),又c>d,所以b=c<a和x|y矛盾,所以此时ij不满足条件 其他情况

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers

原文链接:https://www.cnblogs.com/xwl3109377858/p/11404050.html Educational Codeforces Round 71 (Rated for Div. 2) A - There Are Two Types Of Burgers There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburg

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

Educational Codeforces Round 79 (Rated for Div. 2)

A. New Year Garland (CF 1279 A) 题目大意 给定红绿蓝三种颜色灯的数量,问能否摆成一排,使得相邻颜色不相同. 解题思路 植树问题.考虑数量最多为\(n\)的颜色的灯俩俩不相邻,那么其他颜色的灯的数量和要大于\(n-1\)即可,大过\(n-1\)的灯直接插到里面就好了. 神奇的代码 #include <bits/stdc++.h> #define MIN(a,b) ((((a)<(b)?(a):(b)))) #define MAX(a,b) ((((a)>

Educational Codeforces Round 85 (Rated for Div. 2)

Educational Codeforces Round 85 (Rated for Div. 2) A. Level Statistics 签到题, 要求第一位维单增, 第二维变化比第一维慢, 直接模拟即可 B. Middle Class 题目大意 每个人有一些财富, 财富值超过x的人称为富人, 由于实行共产主义, 你可以将某些人的财产重新分配使得富人最多 解题思路 直接按财富值排序, 从大到小加入富人集合, 如果当前富人集合财富平均值小于x就break掉 C. Circle of Monst