CodeForces 593A】的更多相关文章

题目链接: http://codeforces.com/problemset/problem/593/A 题意: 给你n个字符串,字符串只包含小写字母,从中选取任意个字符串,拼成一封信,这封信中至多有两种字符,输出信的最大长度. 题解:对a~z进行编号为1~26,开一个二维数组a,a[i][j]表示出现第i个字母和第j个字母的长度,对所有的字符串进行处理,然后就可以对数组a进行扫描: len=max(a[i][j]+a[j][i]+a[i][0]+[j][0]) ;(0<i<27,i<j…
Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just de…
暴力. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; struct X { +]; int len; int num; ]; }s[]; int n; int main() { scanf("%d",&n); ;i<=n;i++) { scanf("%s",s[i].s…
CodeForces 593A 题意:n个字符串,选一些字符串,在这些字符串中使得不同字母最多有两个,求满足这个条件可选得的最多字母个数. 思路:用c[i][j]统计文章中只有i,j对应两个字母出现的字符串的长度和. c[i][i]表示只有一个字母字符串的累计长度. c[i][j]  i!=j时:i>j  i<-->j i与j交换. 统计完以后,i,j 0->26.   i==j   ans=max(max,c[i][i])      i!=j     ans=max(max,c[…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连通图)且这颗树中必须包含节点1 然后将这颗子树中的所有点的点权+1或-1 求把所有点权全部变为0的最小次数(n<=10^5) 题解: 因为每一次的子树中都必须有1,所以我们得知每一次变换的话1的权值都会变化 所以我们以1为根 现在,我们发现,如果一个节点的权值发生变化,那么他的父节点的权值一定发生变…