Codeforces Round #394 (Div. 2) C.Dasha and Password(暴力)
http://codeforces.com/contest/761/problem/C
题意:
给出n个串,每个串的初始光标都位于0(列)处,怎样移动光标能够在凑出密码(每个串的光标位置表示一个密码的字符,密码至少包含3种字符:数字,小写字母,特殊符号)的情况下使得移动的光标步数最小。
思路:
因为每个串只提供一个密码,所以我们先预处理计算出每个字符串3种字符的最少移动步数。
然后接下三重循环枚举,分别表示数字,小写字母,特殊符号由第i,j,k行提供。
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstdio>
using namespace std; const int inf=; int n,m;
char s[][];
int w[][]; int main()
{
//freopen("D:\\input.txt", "r", stdin);
while(~scanf("%d%d",&n,&m))
{
for(int i=;i<n;i++)
scanf("%s",&s[i]);
for(int i=;i<n;i++)
{
w[i][]=w[i][]=w[i][]=inf;
for(int j=;j<m;j++)
{
if(isdigit(s[i][j])) w[i][]=min(w[i][],min(j,m-j));
else if(islower(s[i][j])) w[i][]=min(w[i][],min(j,m-j));
else w[i][]=min(w[i][],min(j,m-j));
}
} int ans=*inf;
for(int i=;i<n;i++)
{
for(int j=;j<n;j++)
{
for(int k=;k<n;k++)
{
if(i==j||j==k||i==k) continue;
ans=min(ans,w[i][]+w[j][]+w[k][]);
}
}
}
printf("%d\n",ans);
}
return ;
}
Codeforces Round #394 (Div. 2) C.Dasha and Password(暴力)的更多相关文章
- Codeforces Round #394 (Div. 2) C. Dasha and Password 暴力
C. Dasha and Password 题目连接: http://codeforces.com/contest/761/problem/C Description After overcoming ...
- Codeforces Round #394 (Div. 2) C. Dasha and Password —— 枚举
题目链接:http://codeforces.com/problemset/problem/761/C C. Dasha and Password time limit per test 2 seco ...
- Codeforces Round #394 (Div. 2) C. Dasha and Password
C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #394 (Div. 2) C. Dasha and Password(简单DP)
C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #394 (Div. 2) B. Dasha and friends 暴力
B. Dasha and friends 题目连接: http://codeforces.com/contest/761/problem/B Description Running with barr ...
- Codeforces Round #394 (Div. 2) B. Dasha and friends —— 暴力 or 最小表示法
题目链接:http://codeforces.com/contest/761/problem/B B. Dasha and friends time limit per test 2 seconds ...
- 【枚举】Codeforces Round #394 (Div. 2) C. Dasha and Password
纪念死去的智商(虽然本来就没有吧……) 三重循环枚举将哪三个fix string作为数字.字母和符号位.记下最小的值就行了. 预处理之后这个做法应该是O(n^3)的,当然完全足够.不预处理是O(n^3 ...
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(分形)
E. Dasha and Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle 构造
E. Dasha and Puzzle 题目连接: http://codeforces.com/contest/761/problem/E Description Dasha decided to h ...
随机推荐
- 【BZOJ3958】[WF2011]Mummy Madness 二分+扫描线+线段树
[BZOJ3958][WF2011]Mummy Madness Description 在2011年ACM-ICPC World Finals上的一次游览中,你碰到了一个埃及古墓. 不幸的是,你打开了 ...
- git下载和上传项目
首先是git的下载和安装: https://www.cnblogs.com/chenxqNo01/p/6372933.html git的简单使用: 从码云 clone 项目: git clone ht ...
- matplotlib 散点图scatter
最近开始学习python编程,遇到scatter函数,感觉里面的参数不知道什么意思于是查资料,最后总结如下: 1.scatter函数原型 2.其中散点的形状参数marker如下: 3.其中颜色参数c如 ...
- [MongoDB] 用户权限管理
在新环境按照原来的步骤新装了MongoDB,结果出现了一些错误,才发现版本升到了2.6.1,用户权限相关的内容全部改掉了. 现在使用Role来管理用户,有一些内置的Role,也可以自定义Role. 内 ...
- 【JavaScript算法】---插入排序
一.什么叫做插入排序法 有一个已经有序的数据序列,要求在这个已经排好的数据序列中插入一个数,但要求插入后此数据序列仍然有序,这个时候就要用到一种新的排序方法——插入排序法 二.核心 插入排序的基本操作 ...
- V2EX的RSS订阅地址
1.全站RSS输出: https://www.v2ex.com/index.xml 2.单独节点RSS输出: http://www.v2ex.com/feed/{节点名}.xml 以shadowso ...
- pta 习题集5-18 打印学生选课清单
假设全校有最多40000名学生和最多2500门课程.现给出每门课的选课学生名单,要求输出每个前来查询的学生的选课清单. 输入格式: 输入的第一行是两个正整数:N(≤≤40000),为前来查询课表的学生 ...
- Oracle AWR 之 通过dbms_workload_repository.awr_report_text(html)函数在客户端生成AWR报告
1.概述 一般情况下,awr报告都是通过在oracle服务器的sqlplus窗口调用$ORACLE_HOME/rdbms/admin/awrrpt.sql脚本生成报告.方法如下: [oracle@lo ...
- Ubuntu proxychains && setProxy及 unsetProxy
https://www.socks-proxy.net/ (ubuntu proxy )[ lantern -addr 0.0.0.0:8787 proxychains4 printenv http: ...
- mysql 数据操作 单表查询 where约束 between and or
WHERE约束 where字句中可以使用: 比较运算符:>< >= <= != between 80 and 100 值在80到100之间 >=80 <= ...