Codeforces Round #329 (Div. 2)A. 2Char(暴力枚举)
来源:互联网 发布:优化xp电脑批处理工具 编辑:程序博客网 时间:2024/06/07 22:10
题目链接
题意:给出n个单词,只有小写字母组成,然后问如何选择单词,使得组成的长度最长,且组合出的串最多只能有2个字母不同。
解法:暴力枚举2个字母的组合情况,然后在判断。
#include<bits/stdc++.h>using namespace std;const int maxn=10005;const int inf=1<<27;string str[maxn];int main(){ int n;scanf("%d",&n); for(int i=0;i<n;i++){ cin>>str[i]; } int ans=0,tmp; for(int i=0;i<26;i++){ for(int j=0;j<26;j++){ tmp=0; for(int k=0;k<n;k++){ bool flag=true; char x='a'+i,y='b'+j; for(int p=0;p<str[k].length();p++){ if(str[k][p]!=x&&str[k][p]!=y){ flag=false; } } if(flag)tmp+=str[k].length(); } ans=max(ans,tmp); } } printf("%d\n",ans); return 0;}
0 0
- Codeforces Round #329 (Div. 2)A. 2Char(暴力枚举)
- Codeforces Round #329 (Div. 2) A. 2Char 字符串+暴力
- 【Codeforces Round 329 (Div 2) A】【暴力枚举】2Char 选单词最多只含2字符
- Codeforces Round #243 (Div. 2) A,B,C(暴力枚举)
- Codeforces Round #286 (Div. 2) A - Mr. Kitayuta's Gift ( 暴力枚举)std:string::insert
- 2Char (Codeforces Round #329 (Div. 2) A)
- Codeforces 593 A. 2Char 【Codeforces Round #329 (Div. 2)】
- Codeforces Round #271 (Div. 2) --A Keyboard (暴力)
- Codeforces Round #283 (Div. 2)---A. Minimum Difficulty (暴力)
- Codeforces Round #281 (Div. 2)A(构造+暴力模拟)
- Codeforces Round #344 (Div. 2) A 题题解 (暴力)
- Codeforces Round #354 (Div. 2)(A)暴力,模拟
- Codeforces Round #433 (Div. 2) A.Fraction(暴力)
- Codeforces Round #318 (Div. 2) A - Bear and Elections 模拟暴力枚举
- Codeforces Round #131 (Div. 2) / 214A System of Equations 暴力枚举
- Codeforces Round #329 (Div. 2) A 2Char
- Codeforces Round #329 (Div. 2)A. 2Char
- Codeforces Round #329 (Div. 2)A. 2Char
- 在AS中logcat的设置过滤信息图文教程
- 分布式日志收集之Logstash 笔记(一)
- mysql REPLACE 语句的使用
- 调试
- MP4文件格式详解——结构概述 (转)
- Codeforces Round #329 (Div. 2)A. 2Char(暴力枚举)
- ios开发常用RGB色值
- Eclipse SVN的使用
- openssl 证书操作命令
- 进销存系统(1):开源ECP编译安装
- Ubantu下创建eclipse快捷图标
- 使用RequireJS来加载MooTools Classes
- C++基础——关于模板的技巧性基础知识(typename、成员模板、模板的模板参数)
- SHA1WithRSA算法-简介