Contest1616 - 备战省赛组队训练赛第十六场FZU Code Carnival

问题 F: Melody

时间限制: 1 Sec  内存限制: 128 MB
提交: 394  解决: 133
[提交] [状态] [命题人:admin]

题目描述

YellowStar is versatile. One day he writes a melody A = [A1, ..., AN ], and he has a standard melody B = [B1, ..., BN ]. YellowStar can split melody into several parts, it can be expressed as: K split position S = [S1, ..., SK], satisfy 1 ≤ S1 < S2 < · · · < SK = N. Melody A and B will be split into K parts:

Two parts of melody are equal while the change of tone is consistent. It can be expressed as:
A = [A1, ..., AM ] equal to B = [B1, ..., BM ] need to satisfy:

Now YellowStar wants each part of his melody A equals to each part of standard melody B. In other words, the following conditions need to be met:

YellowStar also wants the number K of split parts as minimum as possible.

 

输入

Input is given from Standard Input in the following format:
N
A1 A2 . . . AN
B1 B2 . . . BN
Constraints
1 ≤ N ≤ 105
1 ≤ Ai, Bi ≤ 109
All Ai are distinct and all Bi are distinct.
All inputs are integers.

 

输出

Print one line denotes the minimal integer K .

 

样例输入

复制样例数据

5
1 3 2 4 5
4 9 10 11 8

样例输出

3

代码:

#include<iostream>
#include<algorithm>
#include<cstring>
const int maxn = 1e5+2;
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[maxn];
    int b[maxn];
    for(int i = 0;i<n;i++)cin>>a[i];
    for(int i = 0;i<n;i++)cin>>b[i];
    int res = 0;
    for(int i = 0;i<n;i++){
        if((a[i] >a[i-1]&&b[i]<b[i-1])||(a[i]<a[i-1]&&b[i]>b[i-1]))
            res++;
    }
    cout<<res+1<<endl;
}

解析:从1到n找出旋律不同的,分割块数加一,输出即可

问题 J: WTMGB

时间限制: 1 Sec  内存限制: 128 MB
提交: 305  解决: 136
[提交] [状态] [命题人:admin]

题目描述

YellowStar is very happy that the FZU Code Carnival is about to begin except that he has to prepare problems for it. Because the statement of each problem is written in English!
YellowStar types the statements slowly witb high error rate. You must notice that the previous word ’witb’ is wrong(the correct word is ’with’). But YellowStar feels too tired, so he thinks a word is the same as another word if the character at each position of the word is adjacent to the corresponding character of the other word on the keyboard. The keyboard is shown in the figure below:

When two characters on ther keyboard have intersections, they are considered to be adjacent. For example,’S’ is adjacent to ’W’,’E’,’A’,’D’,’Z’ and ’X’.
Now YellowStar asks you to write a program to check whether two strings are the same. Print ’Yes’ if they are the same, and ’No’ otherwise(without the quotes).

 

输入

Input is given from Standard Input in the following format:
S1
S2
Constraints
1 ≤ | S1 | = | S2 | ≤ 103
S1 and S2 consist only of upper-case English letters.

 

输出

Print one line denotes the answer.

 

样例输入

复制样例数据

S
U

样例输出

No

分析:直接暴力,找相邻的字符

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值