761C Dasha and Password[简单dp]

高通量测序数据分析:RNA-seq 深度测序相关数据库与数据格式 SRA toolkit 一、NCBI 和EBI、DDBJ组成INSDC,数据内容相同所以找NCBI就行。 (一)NCBI常用数据库 GenBank:遗传序列数据库,收集了所有公开的DNA序列及其注释 GEO (Gene Expression Omnibus) :收集整理各种表达芯片数据,后来加入了甲基化、lncRNA、miRNA、CNV等其他芯片,还有高通量测序数据... 阅读详情

C. Dasha and Password
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements:

  • There is at least one digit in the string,
  • There is at least one lowercase (small) letter of the Latin alphabet in the string,
  • There is at least one of three listed symbols in the string: '#', '*', '&'.

Considering that these are programming classes it is not easy to write the password.

For each character of the password we have a fixed string of length m, on each of these n strings there is a pointer on some character. The i-th character displayed on the screen is the pointed character in the i-th string. Initially, all pointers are on characters with indexes 1 in the corresponding strings (all positions are numbered starting from one).

During one operation Dasha can move a pointer in one string one character to the left or to the right. Strings are cyclic, it means that when we move the pointer which is on the character with index 1 to the left, it moves to the character with the index m, and when we move it to the right from the position m it moves to the position 1.

You need to determine the minimum number of operations necessary to make the string displayed on the screen a valid password.

Input

The first line contains two integers n, m (3 ≤ n ≤ 50, 1 ≤ m ≤ 50) — the length of the password and the length of strings which are assigned to password symbols.

Each of the next n lines contains the string which is assigned to the i-th symbol of the password string. Its length is m, it consists of digits, lowercase English letters, and characters '#', '*' or '&'.

You have such input data that you can always get a valid password.

Output

Print one integer — the minimum number of operations which is necessary to make the string, which is displayed on the screen, a valid password.

Examples
input
3 4
1**2
a3*0
c4**
output
1
input
5 5
#*&#*
*a1c&
&q2w*
#a3c#
*&#*&
output
3

题意:给定m,n 接下来有m行n列的字符。 每一行自成一个串,初始状态下,每行各有一个指针,指向每行的第一个字符,指针可移动,每次移动一个距离,可左右移动,(0位置左移动为n-1)求最小的移动次数,使得所有指针中至少包含一个小写字母,一个数字,一个*#&符号中的一个。

思路:首先对每一行字符串求得三个数值a,b,c,表示得到小写字母,得到数字,得到给定字符所用的最小次数。

然后对所有的abc遍历所有取得可能,只要保证不来自同一字符串即可。

代码:

#include<iostream>
#include<algorithm>
using namespace std;
int n, m;
int a[55], b[55], c[55];
char str[55];
int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
        a[i] = b[i] = c[i] = 55;

    for(int i = 0; i < n; ++i)
    {
        cin >>str;
        for(int j = 0; j < m; ++j)
        {
            if(str[j] >= 'a' && str[j] <= 'z') a[i] = min(a[i], min(j, m - j));
            else if(str[j] >= '0' && str[j] <= '9') b[i] = min(b[i], min(j, m - j));
            else if(str[j] == '*' || str[j] == '#' || str[j] == '&') c[i] = min(c[i], min(j, m -j));
        }
    }

    int result = 0xffffff;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)  if(j != i)
                        for(int k = 0; k < n; ++k)  if(k != j)
                            result = min(result, a[i]+b[j]+c[k]);
    cout << result;
}


【通信协议】GATT 与 BLE HID 工作原理详解 详细介绍BLE HID 跟GATT工作原理与两者的交互关系 阅读详情

相关推荐

sap销售发货的流程_SAP销售订单发货后如何实现发票的自动创建?

问SAP销售订单发货后如何实现发票的自动创建?答业务场景有些快消零售企业,SAP系统单据量大,单据金额少,一般在销售发货后即可确认收入。此时无需人工在系统内操作VF01或者VF04进行开票操作,可将该操作设置成后台作业进行自动批量开票,具体操作如下:1、定义任务:VF06输入完以上信息,点击保存进入以下界面:说明:当前日期的意思是“开票的日期”等于“系统电脑中的当前日期”当前日期+/-...

weixin_42358409的博客 3358

Dasha and Password - 每天一把CF - 20201101

20201030 dp 761C 1500 题目 原题链接:https://codeforces.com/problemset/problem/761/C 思路 https://www.cnblogs.com/HDUjackyan/p/8996136.html 题意:有 n 个字符串,每个字符串的长度是m,如果认定一个字符串是一个密码,则必须满足: 1:至少有1个数字。2:至少有一个小写字母。3:至少有一个 #、*或& 现在有n个光标,每个光标指向这 n 个字符串。现在可以移动光标,最后使得所.

北北北 648

从0到1做AI漫剧:即梦+豆包+剪映+红果全流程实战

AI视频生成正在重塑内容创作的生产方式,它让原本高门槛的影视制作,变成了一条由文本、画面、剪辑与分发环节协同的流水线。理解其底层原理,在于将大模型的语义理解、图像生成与视频合成能力,与工程化的流程管理相结合,从而实现从创意到成片的自动化输出。这种技术的价值,不仅体现在降低制作成本,更在于让个人创作者能够独立完成高质量短剧,并快速迭代内容。在短剧、短视频、广告营销等场景中,利用即梦生成画面、豆包编写剧本、剪映完成剪辑、红果进行分发的组合,已成为一种被广泛验证的实践路径。本文聚焦AI漫剧制作,从环境准备、分镜设

weixin_34072637的博客 380

文章标题 coderforces 761C : Dasha and Password(贪心+暴力)

Dasha and PasswordAfter overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements

Wang_SF2015的博客 873

硬件基础(4):(6)高精度ADC设计中模拟地与数字地的划分与连接

在实际 PCB 设计中,**接地与布线**对于获得干净的参考电压和高精度 ADC 测量至关重要。下面详细阐述**如何在硬件层面减少数字噪声耦合到模拟电路、保障参考电压的稳定性**。

FCZlll的博客 2642

ABAP Cloud 开发教程的文章目录

本教程涵盖 ABAP 云端 Client 处理、多租户架构、ABAP Cloud开发、动态编程优化、SQL语法改进等技术主题。最新版本1.0.0(更新至2025-12-12),包含197篇文章,重点文章包括《ABAP Client Handling与隔离机制》《ABAP Platform 2021泛型编程》《SAP BTP ABAP多租户应用开发》等,为开发者提供从基础到进阶的实战指南。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1793

CF761 C. Dasha and Password (DP)

传送门 C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After overcoming the sta

blanKey的博客 898

某音私信接口二进制解析

本文探讨了某音私信接口的二进制请求处理过程,重点分析了请求体中的非文本字符和混合编码结构。文章详细描述了编码过程,包括使用Protocol Buffers的序列化方法将结构化数据转换为字节流,并通过Uint8Array包装成二进制数组。作者展示了如何提取和补全s.encode方法,并将其转化为Base64字符串以便在Python中解码执行

码王吴彦祖的博客 900

Dasha and Password (暴力+贪心)

After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements: There is at

codeswarrior的博客 389

基于Simulink环境,提供一个关于如何对EMI抑制的DC-DC变换器进行仿真建模的示例

EMI定义:电磁干扰是指任何能中断、阻碍、降低或限制电气设备有效性能的电磁能量。重要性合规性:确保产品符合国际和地方的EMC标准。可靠性:减少因外部或内部EMI导致的系统故障风险。挑战滤波设计:合理设计输入输出滤波器以抑制传导EMI。布局与接地:良好的PCB设计对于减少辐射EMI至关重要。屏蔽:使用金属屏蔽来保护敏感电路不受外界干扰。首先明确要模拟的任务内容。设计一个能够在高频操作下有效抑制EMI的DC-DC变换器。根据工作频率和谐振元件值确定合适的滤波器参数。

xiaoheshang_123的博客 144

【雕爷学编程】Arduino动手做(71)---红外遥控器及接收模块3

雕爷学编程,Arduino动手做,开源硬件,创客传感器,红外遥控器及接收模块

雕爷学编程 2284

CodeForces - 761C Dasha and Password (思维 暴力)

       题意:给出n个字符串,每个串的初始光标都位于0(列)处,问你怎样移动光标能够在凑出密码(每个串的光标位置表示一个密码的字符,密码至少包含3种字符:数字,小写字母,特殊符号)的情况下使得移动的光标步数最小。      题解:分别把数字、字母、3种字符定义为第0类、第1类、第2类。            b[i][j]  代表当取第i个字符串,取第j类字符的最小距离,b[i][0]...

hxxjxw的博客 324

华为OD面试八股文嵌入式C语言基础问题及答案(一)

本文总结了C语言编程中的10个关键知识点:1.宏定义MIN的实现方法;2.嵌入式无限循环的两种写法;3.变量a的8种不同定义方式;4.static关键字的三种作用;5.const关键字的含义和使用场景;6.volatile关键字的含义及三个应用实例;7.变量存储位置(栈区、静态区、堆区);8.32位系统指针位数;9.局部与全局变量重名规则;10.引用与指针的三点区别。这些内容涵盖了宏定义、变量声明、存储类别、指针等C语言核心概念,对嵌入式开发和系统编程具有重要参考价值。

m0_50382756的博客 160

CF761C Dasha and Password(线性dp)

洛谷链接 https://www.luogu.com.cn/problem/CF761C 题目大意 给n个字符串,每个长m,初始光标都在每个字符串的开头位置,通过移动光标,从n个字符串中各选择一个字符,构成密码,(移动光标时把长度为m的字符串当做一个环),密码必须满足有至少一个小写字母,至少一个数字,至少一个其他字符(# & *),求最小移动次数。 数据范围 3<=n<=50,...

October の 补题记录 343

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

CodeForces 761C Dasha and Password (暴力DP)

题目链接:http://codeforces.com/problemset/problem/761/C 暴力DP #include<bits/stdc++.h> #include<iostream> using namespace std; #define debug puts("YES"); #define rep(x,y,z) for(int (x)=(y)...

满月照亮的路 205

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

【CodeForces - 761C Dasha and Password】 暴力 + DP

D - Dasha and Password After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the followi

于心有愧丶 445

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

codeforces 761 C. Dasha and Password(多维dp)

题目链接:http://codeforces.com/contest/761/problem/C 题意:给出n行的字符串每一列都从第一个元素开始可以左右移动每一行字符串都是首位相连的。 最后问最少移动几次能够构成一个合理字符串,构成方法每一行取当前位置那个数。只要这个字符串 中有数字,有小写字母,有特殊符号就算合理。 先预处理一下每行到达各种符号所要移动的最小距离,最后设p[i]...

awow80285的博客 149

【CodeForces - 761C】Dasha and Password (暴力可过,标解dp,字符串,有坑总结)

题干: After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements: There is ...

xuanweiace的博客 789

codeforces761 C. Dasha and Password

题目大意:这是一个类似组合密码的东西。初始状态密码设置在第一列,我们可以通过拨动来改变每一行的密码。合法的密码必须满足三个条件:1.至少有一个数字。2.至少有一个小写字母。3.至少有一个特殊字符(*&amp;#)问最少拨动多少下就能得到合法的密码。思路:分组背包加状态压缩#include &lt;bits/stdc++.h&gt; using namespace std; char s[55]; ...

题目实力吊打我,怎么能说我菜 286

C. Dasha and Password-C. Dasha and Password-暴力|dp思想

http://codeforces.com/contest/761/problem/C 给定一个char组 n*m的 问你每个组各取 数字 ,字母 和 & * # 问你最少操作。 类似一个密码锁,最开始都咋第一排。 n4暴力(数据太小) dp思想明天补。#include <iostream> #include <cstdio> #include <cstdlib> #include

天与云与山与水 349

C. Dasha and Password 预处理 + dp

http://codeforces.com/contest/761/problem/C 对于每一个字符串,可以预处理出其到达数字,字母,和特殊符号所需的最小步数。 然后就是在n个东西中,选出数字、字母和特殊符号,至少一个,所需的最少步数。 因为第一个选了数字的话,它就不能选字母的了,然后比赛的时候发现这就是二分图,然后就上了km的模板。(太笨了我) 虽然过了,但是明显正解不是这个。 ...

weixin_30667301的博客 92

Codeforces Round #394 (Div. 2) C. Dasha and Password 暴力

C. Dasha and Password 题目连接: http://codeforces.com/contest/761/problem/C Description After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password...

weixin_30299709的博客 116

【Codeforces 761 C Dasha and Password 】

C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputAfter overcoming the stairs Dasha came to classes. She needed

楚江枫 560

【codeforces 761C】Dasha and Password(动态规划做法)

time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output After overcoming the stairs Dasha came to classes. She needed to write a pas...

AWCXV 229

[Codeforces Round #394 DIV2C (CF761C)] Dasha and Password

题意给定一个密码锁,密码锁有nn环,每一环mm个字符,你可以旋转每一环向左或向右,询问最少旋转几次能让现在的密码至少有一个数字,一个小写字母和一个给定符号(*或&或#) n,m≤50n,m\le 50题解对于每个环都找出来转到数字,字母,符号所需次数,n3n^3循环就完了,一道大水题。复杂度O(n3m)O(n^3m) 但是这题有更优算法。 我们对得到数字的次数取出最小的三个,字母和符号也是,这

ztx 439

C. Dasha and Password

C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After overcoming the stairs Dasha came to class

樱花满地集于我心,楪舞纷飞祈愿相随 587
上一篇: 机器学习笔记(一):梯度下降算法,随机梯度下降,正规方程
下一篇: 761D Dasha and Very Difficult Problem[数学][思维]
Qer_
博客等级 码龄11年 34粉丝 69原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值