L - The Last Supper


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

Keivan will leave the country to study abroad. He invited all his friends to a restaurant for his goodby party. He asked them to stay home for two weeks before the party night, to be sure that none of them has contracted the coronavirus.

توضیح تصویر

Tomaketheparty short, Keivan reserved a round table, specified each person’s seat, and put his guests’ order in front of their seats. The party was over, and everyone enjoyed the food. Unfortunately, some guests had fevers right after the party. Therefore, Keivan asked them all to take the PCR tests again. The results of the tests were not as all hoped for. Coronavirus had affected some of his friends. We know that a PCR test could have a false negative. But, it never has a false positive. This means that if a person has a negative result, he may be healthy or has contracted the coronavirus. But, people with positive results have definitely contracted the virus.

Now, Keivan is confused. He does not know how his friends got sick. The restaurant manager told him that exactly one of his friends ordered a bat soup. He is determined to find those who may have ordered this soup. Thus he asked for the video check. Unfortunately, the video captured by the restaurant’s CCTV has a low quality, making it hard to see their orders. However, he could see their activities and their timings. From these activities, he wants to find those who may have ordered the bat soup and spread the coronavirus.

Keivan wrote down his friends’ activities in chronologically ascending order. Each activity tells that a person talks to one of his adjacent neighbors. We know that the person who ate the bat soup got affected by the virus immediately. After that, if a sick person talks to his neighbor, the second person gets sick. There are no other ways for virus transmission.

ورودی🔗

The first line of the input has three positive integers: nn, mm and qq (1mn1051 \leq m \leq n \leq 10^5, 1q1051 \leq q \leq 10^5) which are the number of guests, the number of sick guests, and the total number of guests activities, respectively. Guests are numbered from 11 to nn in clockwise order. It means that the guest i+1i + 1 is the left neighbor of guest ii (guest 11 seats in the left chair of nn). The next line contains exactly mm distinct integers aia_i (1ain1 \leq a_i \leq n); each denotes one of guests who are affected by the coronavirus.

The next qq lines are guests’ activities in the chronologically ascending order of time. Each line contains an integer bib_i (1bin1 \leq b_i \leq n) following by a character cic_i (cic_i LL,RR). This indicates that the guest bib_i, talks to his left (LL) or his right (RR) person.

خروجی🔗

Print all the guests who might have ordered the bat soap, in the ascending order, in one line.

مثال‌ها🔗

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

3 1 3
2
1 L
2 L
3 L
Plain text

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

1 2 
Plain text

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

3 2 2
2 3
1 R
3 R
Plain text

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

1 3 
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.