luogu#P4439. [COCI2017-2018#3] Aron
[COCI2017-2018#3] 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 person in line.
输出格式
You must output the required number from the task.
题目大意
Aron 为了给他的朋友们买礼物正在礼物店排队,它的前面有 个人。
但是它发现有些人是在等待他前面的朋友购买,而并非在排队买单。我们认为紧跟在同一个人身后,穿着同样颜色衣服的人是这个人的朋友。一个人的朋友会在这个人购物后随之离开。
现在按照顺序给定排在 Aron 前面的人的衣服的颜色,输出 Aron 还需要等待多少人购物。
3
C
Z
P
4
6
C
C
P
C
Z
Z
5
6
B
B
B
B
B
B
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.