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

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

E – Flower Lovers


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

As you know, it was Valentines day just a couple of days ago and just because students of SBU are amorous, we have changed the whole statement of this problem, just for you :).

Ok, Let’s talk business. We have two groups of people each standing on a line in front of the other group playing a game. Let’s name them group A and B and let’s say group A members are all females (because ladies come first) and all group B members are males. Each person has a basket for gathering flowers (of-course from the other gender 😑 ) and lots of flowers to throw for the other group. (It’s not legal to throw flowers from baskets). Each basket have a limited capacity for collecting flowers. YES we know, this is a very lovely problem. ☺

Game is played in turns (They play simultaneously). In each turn, every person should take one of it’s beautiful and fragrant flowers and throw it in to one of his/her lovers on the other side. If a person’s basket is full, he/she leaves the stage Immediately, and perhaps going to sing the love songs in the streets…. never-mind. Though it’s a game and they all enjoy playing it, it’s a game (horror songs playing… 🎶 ) and the winner is the group exiting last. In other words, a group wins the game if there are no more members of the other group on the stage. We know both group A and group B play optimally and can communicate with each other. Shamir loves valentines and he’s busy getting prepared, So it’s up to you to decide which group will win the game…

ورودی🔗

The first line of input shows the number of test cases TT. Each test case will contain 33 lines. 1T1001 \leq T \leq 100

The first line contains two space separated integers NN and MM indicating number of group A and group B members respectively. 1N,M10001 \leq N, M \leq 1000

Second and third line will contain NN and MM space separated integers indicating initial capacity of baskets for group A and B members respectively. It’s guaranteed sum of all numbers in second and third line will not exceed 10610^6. ai+bi106 \sum a_i + \sum b_i \leq 10^6

خروجی🔗

For each test case, print in a single line whether group A wins or group B. If no one wins print we will all sing songs together

مثال‌ها🔗

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

1
3 6
3 4 4
1 1 1 4 3 2
Plain text

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

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