A. 2Char

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/593/problem/A

Description

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 decided to take a random one from magazine 26Char. However, before sending it to the magazine 2Char, he needs to adapt the text to the format of the journal. To do so, he removes some words from the chosen article, in such a way that the remaining text can be written using no more than two distinct letters.

Since the payment depends from the number of non-space characters in the article, Andrew wants to keep the words with the maximum total length.

Under two situations the player could score one point.

⋅1. If you touch a buoy before your opponent, you will get one point. For example if your opponent touch the buoy #2 before you after start, he will score one point. So when you touch the buoy #2, you won't get any point. Meanwhile, you cannot touch buoy #3 or any other buoys before touching the buoy #2.

⋅2. Ignoring the buoys and relying on dogfighting to get point.
If you and your opponent meet in the same position, you can try to
fight with your opponent to score one point. For the proposal of game
balance, two players are not allowed to fight before buoy #2 is touched by anybody.

There are three types of players.

Speeder:
As a player specializing in high speed movement, he/she tries to avoid
dogfighting while attempting to gain points by touching buoys.
Fighter:
As a player specializing in dogfighting, he/she always tries to fight
with the opponent to score points. Since a fighter is slower than a
speeder, it's difficult for him/her to score points by touching buoys
when the opponent is a speeder.
All-Rounder: A balanced player between Fighter and Speeder.

There will be a training match between Asuka (All-Rounder) and Shion (Speeder).
Since the match is only a training match, the rules are simplified: the game will end after the buoy #1 is touched by anybody. Shion is a speed lover, and his strategy is very simple: touch buoy #2,#3,#4,#1 along the shortest path.

Asuka is good at dogfighting, so she will always score one point by dogfighting with Shion, and the opponent will be stunned for T seconds after dogfighting.
Since Asuka is slower than Shion, she decides to fight with Shion for
only one time during the match. It is also assumed that if Asuka and
Shion touch the buoy in the same time, the point will be given to Asuka
and Asuka could also fight with Shion at the buoy. We assume that in
such scenario, the dogfighting must happen after the buoy is touched by
Asuka or Shion.

The speed of Asuka is V1 m/s. The speed of Shion is V2 m/s. Is there any possibility for Asuka to win the match (to have higher score)?

Input

The first line of the input contains number n (1 ≤ n ≤ 100) — the number of words in the article chosen by Andrew. Following are n lines, each of them contains one word. All the words consist only of small English letters and their total length doesn't exceed 1000. The words are not guaranteed to be distinct, in this case you are allowed to use a word in the article as many times as it appears in the input.

Output

Print a single integer — the maximum possible total length of words in Andrew's article.

Sample Input

4
abb
cacc
aaa
bbb

Sample Output

9

HINT

题意

给你一堆单词,然后你只能选包含某两种字母的单词出来

然后问你最多能够选的单词长度总和是多少

题解:

直接暴力枚举两个字母就好了,然后再直接把所有单词都for一遍

代码

#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std; string s[];
int main()
{
int n;scanf("%d",&n);
for(int i=;i<n;i++)
cin>>s[i];
int ans = ;
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
int tmp = ;
for(int k=;k<n;k++)
{
int flag = ;
for(int p=;p<s[k].size();p++)
{
if(s[k][p]!=char(i+'a')&&s[k][p]!=char(j+'a'))
{
flag = ;
}
}
if(flag==)
tmp += s[k].size();
}
ans = max(ans,tmp);
}
}
cout<<ans<<endl;
}

Codeforces Round #329 (Div. 2) A. 2Char 暴力的更多相关文章

  1. Codeforces Round #329 (Div. 2)

    推迟了15分钟开始,B卡住不会,最后弃疗,rating只涨一分...   水(暴力枚举) A - 2Char /******************************************** ...

  2. Codeforces Round #307 (Div. 2) B. ZgukistringZ 暴力

    B. ZgukistringZ Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/probl ...

  3. Codeforces Round #329 (Div. 2) B. Anton and Lines 逆序对

    B. Anton and Lines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/pr ...

  4. Codeforces Round #329 (Div. 2) D. Happy Tree Party 树链剖分

    D. Happy Tree Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/p ...

  5. Codeforces Round #328 (Div. 2) A. PawnChess 暴力

    A. PawnChess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/ ...

  6. Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)

    A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...

  7. Codeforces Round #329 (Div. 2)B. Anton and Lines 贪心

    B. Anton and Lines   The teacher gave Anton a large geometry homework, but he didn't do it (as usual ...

  8. Codeforces Round #329 (Div. 2) D. Happy Tree Party LCA/树链剖分

    D. Happy Tree Party     Bogdan has a birthday today and mom gave him a tree consisting of n vertecie ...

  9. Codeforces Round #369 (Div. 2) A B 暴力 模拟

    A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. Delphi 为什么它提示PCHAR是不安全的类型呢 Unsafe type 'PChar'

    DELPHI7已经考虑到了移植到点NET的问题,在点NET里,指针是不安全的.至于为什么有的人遇到,有的人没有遇到,那是因为各人的编译选项不同.在Project菜单下选Options“Compiler ...

  2. Oracle OCI-22053:溢出错误解决方法

    原文 Oracle OCI-22053:溢出错误解决方法 Oracle 数值数据类型最多可存储 38 个字节的精度.当将 Oracle 数值转换为公共语言运行库数据类型时,小数点后边的位数可能过多,这 ...

  3. C# chart,有关如何在鼠标移动到Series上时显示节点及数据 (有待继续更新)

    一.效果与思路 效果: 解决方案1 用chart的mousemove时间,实时跟踪鼠标最近的X轴的位置,然后把cursorX设置到那个位置上,让用户知道我是选的那一个X的值,同时用tooltip显示该 ...

  4. 1048 图的宽度优先遍历序列 c语言

    描述 图(graph)是数据结构 G=(V,E),其中V是G中结点的有限非空集合,结点的偶对称为边(edge):E是G中边的有限集合.设V={0,1,2,……,n-1},图中的结点又称为顶点(vert ...

  5. HDU 3853-loop(概率dp入门)

    题意: r*c个方格,从(1,1)开始在每个方格可释放魔法(消耗能量2)以知,释放魔法后可能在原地.可能到达相邻的下面格子或右面格子,给出三者的概率 求要到达(R,C)格子,要消耗能量的期望值. 分析 ...

  6. codeforces 691E Xor-sequences 矩阵快速幂

    思路:刚开始 n个元素,a[i][j]代表以i开头,j结尾的二元组符合条件的有多少 这是等于长度为2的数量 长度为3的数量为a*a,所以长度为n的数量是a^(k-1) 然后就是矩阵快速幂,然而我并不能 ...

  7. Handling HTTP 404 Error in ASP.NET Web API

            Introduction: Building modern HTTP/RESTful/RPC services has become very easy with the new AS ...

  8. webstorm下设置sass

    关于sass,就不想多说什么了.只要你有css基础,十分钟入门好吗.可以参考下资料:http://www.w3cplus.com/sassguide/ 今天想说的是webStorm下如何实现sass自 ...

  9. bzoj 1798 [Ahoi2009]Seq 维护序列seq(线段树+传标)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1798 [题意] 给定一个序列,要求提供区间乘/加,以及区间求和的操作 [思路] 线段树 ...

  10. 【转】VC6.0附带小工具软件一览

    )ActiveX Control Test Container称为"ActiveX 控件测试容器",顾名思义,此工具的主要功能就是测试ActiveX 控件,可以通过改变Active ...