Codeforces 1194A. Remove a Progression】的更多相关文章

传送门 再一次题目看错浪费一小时...退役算了 自己手玩一下发现划掉的都是奇数,最后所有奇数都划掉了,证明也挺显然的 所以直接输出 $2m$ 即可 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long ll; inline int read()…
[CodeForces - 1272D] Remove One Element [线性dp] 标签:题解 codeforces题解 dp 线性dp 题目描述 Time limit 2000 ms Memory limit 262144 kB Source Codeforces Round #605 (Div. 3) Tags brute force   dp   *1500 Site https://codeforces.com/problemset/problem/1272/D 题面 Exam…
题目链接:900C Remove Extra One 题意: 首先record是指这个数比数列前面的所有数都大,给了n个数(1-n),删掉一个数,让整个数列的record值达到最大. 题解: 刚开始我的思路是求这个数列中前面比这个数大的有几个(因为只有前面只有一个数大于这个数的数可以增加record值)求出后找比求出个数为1的数大的最近数.后来发现这中方法代码量实在太大了,而且在求出后再求最近的大于这个数的数的复杂度也好像不够. 后来看了题解,发现只要换一种思路就很简单,那就是求删除某个位置上的…
You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible. We remind that in a sequence of numbers a1, a2, ..., ak the element ai is a record if for every integer j (1 ≤ j < i) t…
https://codeforces.com/contest/1203/problem/D2 上次学了双指针求两个字符串之间的是否t是s的子序列.但其实这个双指针可以求出的是s的前i个位置中匹配t的最长的前缀.反过来求一次可以得到最长的后缀. 然后怎么找要删除的位置呢?暴力n^2肯定可以,然后线性写挂到自闭. 枚举位置[i,j),注意j可以取相等,所以预处理前后缀的时候把n位置的后缀也算好. 去除子串[i,j),那么剩下的就是[0,i-1]和[j,n-1]两个子串,他们匹配的长度加起来超过tl就…
time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output Problem Description Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progression…
[链接] 我是链接,点我呀:) [题意] 让你在n个数字中再加入一个数字 使得这n+1个数字排序之后 相邻两个数字的差都相同 [题解] 注意相邻为0的情况 这种情况 只有全都相同才行 只有一种情况 然后就是样例里的a[i]-a[i-1]只有两种数字 然后较小的a[i]-a[i-1]有n-2个,较大的a[i]-a[i-1]有1个,然后较大的是较小的两倍 注意这些细节就好了 [代码] import java.io.*; import java.util.*; public class Main {…
题意 给你一个字符串,字符\(s_i\)可以被伤处当且仅当\(s_{i-1}=s_i-1\)或\(s_{i+1}=s_i-1\).问最多能删几个字符. 解题思路 其实,有个很简单的做法就是从\(z\)开始枚举到\(b\),能删就删,因为如果现在枚举到的字符删不掉,之后也不可能能删掉. 但是比赛的时候我突发奇想,搞了个\(O(n^4)\)的区间dp,毕竟\(\left|s\right|\)最大只有100. 大概意思就是区间dp枚举区间,转移就从左往右扫,能删就删. 乱搞也搞过了.jpg AC代码…
题目链接:http://codeforces.com/contest/1194                                            A.Remove a Progression time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output You have a list of numbers from 11…
目录 Contest Info Solutions A.Remove a Progression B.Yet Another Crosses Problem C.From S To T D.1-2-K Game E.Count The Rectangles Contest Info Practice Link Solved A B C D E F G 5/7 O O O O Ø - - O 在比赛中通过 Ø 赛后通过 ! 尝试了但是失败了 - 没有尝试 Solutions A.Remove a…
A. Remove a Progression 签到题,易知删去的为奇数,剩下的是正偶数数列. #include<iostream> using namespace std; int T; int n,x; int main(){ cin>>T; while(T--){ cin>>n>>x; cout<<x * 2<<endl; } return 0; } B. Yet Another Crosses Problem n*m存在上界,…
poj1112 Team Them Up! 补图二分图+dp记录路径codeforces 256A Almost Arithmetical Progression dp或暴力 dp[i][j] = dp[j][last] + 1 ;codeforces 294C Shaass and Lights 组合 计算方法的优化codeforces 298C Parity Game 纯粹证明题,想法很好.codeforces 256D 还不会,很好的一个dppoj3417 Network LCA + 树形…
C. Geometric Progression Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/C Description Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length…
Geometric Progression Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 567C Description Polycarp loves geometric progressions very much. Since he was only three years old, he loves only t…
原题地址:http://codeforces.com/contest/758/problem/F F. Geometrical Progression time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output For given n, l and r find the number of distinct geometrical pro…
题目链接:http://codeforces.com/problemset/problem/567/C C. Geometric Progression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves geometric progressions very much. Since he was on…
题目传送门 /* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数.别人的代码很短,思维巧妙 */ /************************************************ * Author :Running_Time * Created Time :2015-8-6 1:07:18 * File Name :C.cpp *******************************************…
链接: https://codeforces.com/contest/1272/problem/D 题意: You are given an array a consisting of n integers. You can remove at most one element from this array. Thus, the final length of the array is n−1 or n. Your task is to calculate the maximum possib…
题目链接:http://codeforces.com/problemset/problem/382/C 题目意思:给定一个序列,问是否可以通过只插入一个数来使得整个序列成为等差数列,求出总共有多少可能的情况,并输出这些数. n = 1 . n = 2 和 整个序列是常数列 的情况比较容易判断.不过要注意n = 2的时候,也需要判断两个数之间是否也可以通过插入一个数来构成等差数列. 关键是讨论n>=3的情况.预处理:把整个输入序列从小到大排序.之后,得到公差是第一要务!如果可以从中插入一个数(这时…
Geometrical Progression n == 1的时候答案为区间长度, n == 2的时候每两个数字都可能成为答案, 我们只需要考虑 n == 3的情况, 我们可以枚举公差, 其分子分母都在sqrt(1e7)以内, 然后暴力枚举就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL,…
题目链接:http://codeforces.com/problemset/problem/1114/E 题意: 交互题,有一个 $n$ 个整数的打乱顺序后的等差数列 $a[1 \sim n]$,保证公差为正整数,你可以询问不超过 $60$ 次来找到该等差数列的首项和公差. 你可以做的询问有两种: 1.询问是否存在某个数字大于 $x$. 2.询问序列中第 $i$ 个数是多少. 题解: 首先可以用二分的方式找到这个等差数列的最大值,由于 $a[i] \in [0,1e9]$,所以最多 $30$ 次…
http://codeforces.com/contest/978/problem/D 题目大意: 给你一个长度为n的b(i)数组,你有如下操作: 对数组中的某个元素+1,+0,-1.并且这个元素只能修改一次 问:是否有操作能吧这个数组变成等差 如果有,请输出把他变成等差的最小步数.否则输出-1: 思路: 定等差的值即可 暴力b1和b2的+1,+0,-1,即可得到等差的值…
题目链接:https://codeforces.com/contest/978/problem/D 题解: 题目的大意就是:这组序列能否组成等差数列?一旦构成等差数列,等差数列的公差必定确定,而且,对于给定的数列,公差的可能性是已知的. 我的解决思路是:对于给定的数列,最后一位数 - 第一位数 / (n -1) 必定是公差,而对于我们要判断的原数列,其最后一位 - 第一位数的值是可以-2,-1,0,+1,+2的,穷举可能性一切公差,找出变动最小的情况.代码如下(有点小复杂,没优化): #incl…
C. Remove Extra One time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum…
C. Geometric Progression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions o…
题目地址:http://codeforces.com/contest/978/problem/A 题解:给一串长度为n的数组,然后删去相同的数字(从右往左). 方法:题目n和数组ai给的范围都很小,所以可以放一个vis[1500]的数组表示1~1000内的数字是否被访问过.从右到左倒着访问,然后再把out数组倒着输出. 代码:(代码较丑,欢迎大佬们批评指正) #include<cstdio> #include<cmath> #include<algorithm> #in…
题目链接:https://codeforces.com/problemset/problem/567/C 题意: 给出长度为 $n$ 的序列 $a[1:n]$,给出公比 $k$,要求你个给出该序列中,长度为 $3$ 的等比子序列的数目. 题解: 首先倒着遍历,用map记录曾经出现过的每个数字的出现次数,然后再用另一个map来记录曾经出现过的所有满足 $(x,kx)$ 的二元组的数目,最后就直接维护答案即可. AC代码: #include<bits/stdc++.h> #define IO (i…
题目链接:https://codeforces.com/contest/1203/problem/D2 题意: 给你S串.T串,问你最长删除多长的子串使得S串里仍然有T的子序列. 思路: 想了好久,先正着跑一下S串,记录T串每一个字符最左边在哪里,再倒着跑一下,记录T串的每一个字符最右边在哪里. 最后跑一下答案: 1. 开头和结尾特判一下,但不是max( L[1]-1 , l1-R[l2] ) , 而是对两个max( L[1]-1 , l1-L[l2]-1 ).max( R[1]-1 , l1-…
题目大概说给一个整数序列,问里面有几个包含三个数字的子序列ai,aj,ak,满足ai*k*k=aj*k=ak. 感觉很多种做法的样子,我想到这么一种: 枚举中间的aj,看它左边有多少个aj/k右边有多少个aj*k,两边个数的乘积就是答案的一部分贡献. 而左边各个数字的个数和右边各个数字可以用两个map维护,一边枚举一边删除或插入. #include<cstdio> #include<map> #include<algorithm> using namespace std…
input n,k 1<=n,k<=200000 a1 a2 ... an 1<=ai<=1e9 output 数组中选三个数,且三个数的下标严格递增,凑成形如b,b*k,b*k*k的种数 做法:先将可以作为第三个数的数放到map中,然后再扫一遍依次统计map中的数作为第三个数的种数,第二个数的种数,第三个数的种数 #include<cstdio> #include<map> struct node { int b;//a[i]作为i1的种数 long lo…