3379 - I Don't Want Strawberry 3379 - Yo No Quiero Fresa 3379 - I Don't Want Strawberry

Statistics Sub: 402 | AC: 128 | AC%: 31,84 | Score: 1,36
Created by Luis Enrique Garcia Marrero
Added by legar (2015-09-29)
Limits
Total Time: 10000 MS | Test Time: 1000 MS |Memory: 256 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

There is a group of N people forming a queue to buy ice cream, everyone wants to buy just one and there are only two flavors: strawberry and chocolate. The ice cream is in a stack, and the seller just has access to the ice cream on the top of the stack. If the first person of the queue wants to buy a flavor different to the one on the top then he has to wait in another special queue until the desire flavor appears on the top of the ice cream stack. If the flavor on the top is the one desired by some people in special queue then the seller must sell it to them (according to original order and with the rule of “first to come first to be served”); otherwise the original queue still working normally. You are given the original queue and stack's distribution and you must find for each person how many people behind him will buy first their ice cream.
;jsessionid=155A798936CCF7E19B42FEE648089608
Hay un grupo de N personas formando una cola para comprar helado, todos quieren comprar un solo helado y hay dos sabores: fresa y chocolate. El helado está en una pila, y el vendedor solo tiene acceso al helado que se encuentra en la cima de la pila. Si la primera persona en la cola quiere comprar un sabor diferente al de la cima de la pila, esta debe esperar en otra cola especial hasta que su sabor deseado se encuentre en la cima de la pila de helados. Si el sabor en la cima de la pila es el deseado por alguna persona en la cola especial entonces se le venderá a esta (de acuerdo con el orden original y con la regla "primero en llegar primero en ser servido"); de lo contrario la cola original sigue funcionando normalmente. A usted le serán dadas las distribuciones de la cola original y de la pila de helados y usted debe encontrar para cada persona cuántas personas detrás de ella compraron primero sus helados.
;jsessionid=155A798936CCF7E19B42FEE648089608
There is a group of N people forming a queue to buy ice cream, everyone wants to buy just one and there are only two flavors: strawberry and chocolate. The ice cream is in a stack, and the seller just has access to the ice cream on the top of the stack. If the first person of the queue wants to buy a flavor different to the one on the top then he has to wait in another special queue until the desire flavor appears on the top of the ice cream stack. If the flavor on the top is the one desired by some people in special queue then the seller must sell it to them (according to original order and with the rule of “first to come first to be served”); otherwise the original queue still working normally. You are given the original queue and stack's distribution and you must find for each person how many people behind him will buy first their ice cream.
;jsessionid=155A798936CCF7E19B42FEE648089608

Input specification

The first line contains an integer N (1 <= N <= 10^5) representing the number of people in the original queue. The second line describes desired flavors of each person in the queue with a string of N characters which are either zero “0” or one “1”, indicating respectively strawberry or chocolate (from person number one to person number N). The third and last line describes flavors in the ice cream stack with a string of N characters which are either zero “0” or one “1”, indicating respectively strawberry or chocolate (from top to bottom). You can safely assume that all persons can be served.
La primera línea contiene un entero N (1 <= N <= 10^5) representando el número de personas en la cola original. La segunda línea describe los sabores deseados por cada persona en la cola con una cadena de N caracteres los cuales son cero “0” o uno “1”, indicando fresa o chocolate respectivamente (desde la primera hasta la última persona). La tercera y última línea describe los sabores en la pila de helados con una cadena de N caracteres los cuales son “0” o uno “1”, indicando fresa o chocolate respectivamente (desde la cima hasta el fondo). Usted puede asumir que todas las personas pueden ser servidas.
The first line contains an integer N (1 <= N <= 10^5) representing the number of people in the original queue. The second line describes desired flavors of each person in the queue with a string of N characters which are either zero “0” or one “1”, indicating respectively strawberry or chocolate (from person number one to person number N). The third and last line describes flavors in the ice cream stack with a string of N characters which are either zero “0” or one “1”, indicating respectively strawberry or chocolate (from top to bottom). You can safely assume that all persons can be served.

Output specification

Output N lines, each one containing an integer representing the number of people that originally were behind the i-th (1 <= i <= N) person and buy first their ice cream.
;jsessionid=155A798936CCF7E19B42FEE648089608
Imprima N líneas, cada una conteniendo un entero representando el número de personas que originalmente estaban detrás de la  i-th (1 <= i <= N) persona y compraron sus helados antes.
The first line contains an integer N (1 <= N <= 10^5) representing the number of people in the original queue. The second line describes desired flavors of each person in the queue with a string of N characters which are either zero “0” or one “1”, indicating respectively strawberry or chocolate (from person number one to person number N). The third and last line describes flavors in the ice cream stack with a string of N characters which are either zero “0” or one “1”, indicating respectively strawberry or chocolate (from top to bottom). You can safely assume that all persons can be served.

Sample input

4
0101
1100

Sample output

2
0
1
0

Hint(s)

http://coj.uci.cu/24h/
http://coj.uci.cu/24h/
http://coj.uci.cu/24h/

Recommendation

We have carefully selected several similar problems: 3954 | 2378 | 2756 | 3419 | 3734 | 2590