当前位置:网站首页>【暑期每日一题】洛谷 P3742 umi的函数
【暑期每日一题】洛谷 P3742 umi的函数
2022-07-01 04:47:00 【AC_Dragon】
题目链接:P3742 umi的函数 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题目背景
umi 找到了一个神秘的函数 f。
题目描述
这个函数接受两个字符串 s1,s2。这些字符串只能由小写字母组成,并且具有相同的长度。这个函数的输出是另一个长度与 s1,s2 相同的字符串 g。g 的第 i 个字符等于 s1 的第i 个字符和 s2 的第 i 个字符的最小值,简单来说,g[i]=min(s1[i],s2[i])。
例如:f("ab","ba")= "aa", f("nzwzl","zizez")="niwel".
她现在有两个相同长度的只有小写字母的字符串 x,y。找出任何一个满足 f(x,z)=y 的
字符串 z。如果找不到这样的字符串的话,请输出-1。
输入格式
第一行给出以下两个字符串的长度 n。
第二行给出一个字符串 x。
第三行给出一个字符串 y。
输出格式
第一行输出一个字符串,代表你找到的符合条件的字符串。找不到的话,请输出-1。
样例 #1
样例输入 #1
2
ab
aa样例输出 #1
ba样例 #2
样例输入 #2
5
nzwzl
niwel样例输出 #2
xiyez样例 #3
样例输入 #3
2
ab
ba样例输出 #3
-1提示
对于 100%的数据,1<=n<=100。
AC code:
#include<iostream>
using namespace std;
int main()
{
int l;
cin>>l;
string s1,s2;
cin>>s1>>s2;
for(int i=0;i<l;i++)
{
if(s2[i]>s1[i])
{
cout<<-1;
return 0;
}
}
cout<<s2;
return 0;
} 边栏推荐
- 神经网络-使用Sequential搭建神经网络
- Fitness without equipment
- RuntimeError: “max_pool2d“ not implemented for ‘Long‘
- Simple implementation of slf4j
- 解决:拖动xib控件到代码文件中,报错setValue:forUndefinedKey:this class is not key value coding-compliant for the key
- Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling
- VR线上展览所具备应用及特色
- Shell之Unix运维常用命令
- Summary of testing experience - Testing Theory
- [FTP] common FTP commands, updating continuously
猜你喜欢
![[pat (basic level) practice] - [simple simulation] 1064 friends](/img/37/0ef0f8aae15ae574be1d76c97497c9.jpg)
[pat (basic level) practice] - [simple simulation] 1064 friends

Tencent has five years of testing experience. It came to the interview to ask for 30K, and saw the so-called software testing ceiling

神经网络-卷积层

分布式全局唯一ID解决方案详解

Neural networks - use of maximum pooling

2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis

2022 G2 power station boiler stoker examination question bank and G2 power station boiler stoker simulation examination question bank

分布式事务-解决方案

解决:拖动xib控件到代码文件中,报错setValue:forUndefinedKey:this class is not key value coding-compliant for the key

How to do the performance pressure test of "Health Code"
随机推荐
The index is invalid
FileOutPutStream
Summary of acl2021 information extraction related papers
【FTP】FTP常用命令,持续更新中……
Introduction to JVM stack and heap
pytorch 卷积操作
最长递增子序列及最优解、动物总重量问题
Maixll dock quick start
Cmake selecting compilers and setting compiler options
C - detailed explanation of operators and summary of use cases
Neural networks - use sequential to build neural networks
科研狗可能需要的一些工具
科研狗可能需要的一些工具
How to use maixll dock
Collect the annual summary of laws, regulations, policies and plans related to trusted computing of large market points (national, ministerial, provincial and municipal)
扩展-Fragment
LeetCode_ 35 (search insertion position)
Technology sharing | broadcast function design in integrated dispatching
神经网络-卷积层
[hardware ten treasures catalogue] - reprinted from "hardware 100000 whys" (under continuous update ~ ~)