打卡信奥刷题(747)用Scratch图形化工具信奥P4439[普及组/提高] [COCI2017-2018#3] Aron

[COCI2017-2018#3] Aron

题面翻译

Aron 为了给他的朋友们买礼物正在礼物店排队,它的前面有 n n n 个人。

但是它发现有些人是在等待他前面的朋友购买,而并非在排队买单。我们认为紧跟在同一个人身后,穿着同样颜色衣服的人是这个人的朋友。一个人的朋友会在这个人购物后随之离开。

现在按照顺序给定排在 Aron 前面的人的衣服的颜色,输出 Aron 还需要等待多少人购物。

题目描述

The holiday season is near! Aron wants to get gifts for his friends in Zagreb, so in order to get them on time, he visited a famous toy store in London. After picking out the gifts, he went to the register and discovered that there were already N people in line. Luckily, he noticed that there were groups of people standing in line, in addition to individual customers. A group of people consists of a customer and their friends waiting for them to complete the purchase.
The moment when the customer is done, they and their friends leave the line.

The people considered a group are standing one behind the other and are wearing shirts of matching colour. Two adjacent groups, adjacent individuals or adjacent individual and a group, will never be wearing shirts of the same colour.

Write a program that will, given the data on the people standing in line, output which person in line Aron is.

输入格式

The first line of input contains the positive integer N (1 ≤ N ≤ 25) from the task.
Each of the following N lines contains a single character, an uppercase letter of the English alphabet that represents the shirt colour of the i t h i^{th} ith person in line.

输出格式

You must output the required number from the task.

样例 #1

样例输入 #1

3
C
Z
P

样例输出 #1

4

样例 #2

样例输入 #2

6
C
C
P
C
Z
Z

样例输出 #2

5

样例 #3

样例输入 #3

6
B
B
B
B
B
B

样例输出 #3

2

提示

Clarification​ ​of​ ​the​ ​second​ ​test​ ​case:

First in line is the group consisting of two people in red shirts. Second in line is an individual in the blue shirt, third in line is an individual in the red shirt, and fourth in line is a group in green shirts. This makes Aron fifth in line.

Scratch实现

在这里插入图片描述

后续

接下来我会不断用scratch来实现信奥比赛中的算法题、Scratch考级编程题实现、白名单赛事考题实现,感兴趣的请关注,我后续将继续分享相关内容

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值