zoukankan      html  css  js  c++  java
  • 【洛谷 4439】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^{th}ith person in line.

    输出格式

    You must output the required number from the task.

    题意翻译

    Aron给他的朋友们买礼物后在礼物店排队,它的前面有n个人,但是它发现有些人实在等待他的朋友而并非在排队买单,并且我们可以认为站在一个人后面的朋友都穿着匹配颜色的衬衫,而两个相邻的群体、相邻的个人或相邻的个人和一个集体将永远不会穿着相同颜色的衬衫。

    编写一个程序,给定排队的人所穿的衣服的颜色,输出Aron在第多少位?

    输入输出样例

    输入 #1
    3
    C
    Z
    P
    
    输出 #1
    4
    输入 #2
    6
    C
    C
    P
    C
    Z
    Z
    输出 #2
    5
    输入 #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.

    题解:快乐红色打卡题

    #include<cstdio>
    #include<iostream>
    #include<cmath>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    #include<queue>
    #include<bits/stdc++.h>
    using namespace std;
    const int N=30;
    int n,cont;
    char a[N];
    int main(){
        
        scanf("%d
    ",&n);
        for(int i=1;i<=n;i++)
            scanf("%c
    ",&a[i]);
        for(int i=1;i<=n;i++)
            if(a[i]!=a[i+1]) cont++;
        cout<<++cont;
        return 0;
    }
  • 相关阅读:
    JPA、Hibernate、Spring data jpa之间的关系
    MySQL8.0的安装、配置、启动服务和登录及配置环境变量
    jdbc和odbc
    Win10下 Java环境变量配置
    SpringMVC框架理解
    看看资深程序员是如何教你破解图形验证码!这不很简单嘛!
    破解极验(geetest)滑动验证码
    java做图片点击文字验证码
    java实现点击图片文字验证码
    什么是HttpOnly
  • 原文地址:https://www.cnblogs.com/wuhu-JJJ/p/11855736.html
Copyright © 2011-2022 走看看