لینک‌های مفید برای شرکت در مسابقه:

در طول مسابقه، می‌توانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.

C – Colonelmo, CaptainH1 and Cluna


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Colonelmo and CaptainH1 were hanging out at Cluna when they noticed something strange. Cluna allows the customers to pay by credit card in a super secure way: The guy at the counter simply asks about your card's password. And if that isn't enough, he will shout it out as loud as possible after he hears it from you.

We know that there are NN people who are going to Cluna today, and the ii-th person's credit card password is equal to ai,a_i, a 44 digit number (possibly containing leading zeroes). We know that the people pay (and therefore tell their password) when they are about to leave the shop. We also have the customers' entrance/exit times. Since the guy at the counter repeats the password in a really loud voice, everybody present in the shop at that particular moment will hear it. A customer can memorize a password if and only if she is present at the shop while the cashier is shouting it and the password which is being told is similar to his own password. Two passwords are said to be similar if and only if one is a rearrangement of the digits of the other one (12341234 is similar to say, 12341234 and 41324132 etc.).

As always, CaptainH1 is quite concerned about security matters. She asks Colonel, how many passwords that belong to other people are known to each of the customers at the end? Colonel is too busy browsing 9gag and knows that CaptainH1 won't give him his kindersurprise if he doesn't answer in time. Can you help him?

ورودی🔗

The first line of input contains an integer NN and in the next line NN space separated Integers a1,a2,,aNa_1, a_2, \dots, a_N.

1N2000 1 \leq N \leq 2000

Next line contains an integer MM indicating total number of entrances/exists that have happened ordered by the time of happening.

0M2000 0 \leq M \leq 2000

Each of following MM lines contains an integer XX denoting person XX will enter the shop if she is not in the shop, or otherwise she will pay and leave the shop.

1XN 1 \leq X \leq N

  • The same person can go to Cluna multiple times.
  • Initially there are no customers in Cluna.

خروجی🔗

Print NN space separated numbers b1,b2,,bNb_1, b_2, \dots , b_N each denoting the number of other people whose password is known to ii-th person.

مثال‌ها🔗

ورودی نمونه ۱🔗

5
1234 4321 2345 3455 5345
10
1
2
2
4
5
4
5
3
1
1
Plain text

خروجی نمونه ۱🔗

1 0 0 0 1
Plain text
  • Person one knows about person two's password.
  • Person five knows about person four's password.
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.