Back
Close

The Magic Parade - Episode 1

Statement

 Goal

The The Magic Parade is coming soon, and you're responsible for security there. Three kinds of mages will participate in the parade: peaceful Water Mages, incendiary Fire Mages, and evil Death Mages.

For the parade, all the mages walk in a line, one after another. For security reasons, there are some rules that must be followed:

There should never be 2 Death Mages standing together, otherwise they start to plot a conspiracy, or they fight each other, or they make trouble in other ways. Since one Death Mage cannot directly follow another Death Mage, you must put at least one other mage between them.

Examples:
🧛🧛 - 🚫 Two Death Mages in a row are not ok (DD).
🧛👩‍🦰🧛 - ✅ Two Death Mages are separated, that's ok (DFD).

There should never be more than 3 Fire Mages in a row, or things will get too explosive. Also, for security reasons, if exactly 3 Fire Mages stand together, there should be at least one Water Mage right after them. Just in case.

Examples:
👩‍🦰👩‍🦰 - ✅ Two Fire Mages in a row are ok (FF).
👩‍🦰👩‍🦰👩‍🦰 - 🚫 Three Fire Mages in a row are not ok (FFF).
👩‍🦰👩‍🦰👩‍🦰🧙 - ✅ Three Fire Mages with Water Mage befind them are ok (FFFW).
🧙👩‍🦰👩‍🦰👩‍🦰 - 🚫 Water Mage cannot watch Fire Mages if he stands before them (WFFF).
👩‍🦰👩‍🦰👩‍🦰👩‍🦰🧙 - 🚫 Four Fire Mages even with Water Mage behind them are not ok (FFFFW).
👩‍🦰👩‍🦰👩‍🦰🧙👩‍🦰 - ✅ Four Fire Mages properly divided are ok (FFFWF).
👩‍🦰👩‍🦰🧛👩‍🦰👩‍🦰 - ✅ Four Fire Mages properly divided are ok (FFDFF).

Water Mages are peaceful and safe, so they can follow each other in unlimited numbers. But they really don't like Death Mages and by no means will stand directly after one. If a Death Mage stands behind them, or if there's someone standing between Water and Death Mages, it's okay - they can tolerate that.

Examples:
🧙🧙🧙🧙🧙 - ✅ Any number of Water Mages in a row is ok (WWWWW).
🧛🧙 - 🚫 Water Mage right behind Death Mage is not ok (DW).
🧙🧛 - ✅ Water Mage right before Death Mage is ok (WD).
🧛👩‍🦰🧙 - ✅ Water Mage behind Death Mage, but not directly is ok (DFW).

You've got a roster of registered mages, and you know how many mages of each type will participate in the parade. Your task is to determine whether it's possible to have the parade, given the mages who want to participate.

Given W Water Mages, F Fire Mages and D Death Mages output either POSSIBLE or IMPOSSIBLE.
Please note, that if nobody registered, though it's totally safe, but still impossible to carry on the parade.

Example:
With W = 1, F = 5 and D = 2 it is possible to carry on the parade. For example, you can arrange mages this way:
👩‍🦰👩‍🦰🧛👩‍🦰👩‍🦰👩‍🦰🧙🧛 (FFDFFFWD)

Cover uses free assets by CraftPix https://craftpix.net and free font by Sharkshock https://www.sharkshock.net.
Input
Line 1: Three integers W, F and D separated by spaces.
Output
Line 1: Either POSSIBLE or IMPOSSIBLE.
Constraints
0 ≤ D ≤ 10^9
0 ≤ F ≤ 10^9
0 ≤ W ≤ 10^9
Example
Input
1 5 2
Output
POSSIBLE

Tags
ConditionsCombinatorics

Difficulty
Easy

Test cases
Example Test
Input
1 5 2
Output
POSSIBLE

Example Validator Validator
Input
1 6 2
Output
POSSIBLE

Conflict Test
Input
1 0 2
Output
IMPOSSIBLE

Conflict Validator Validator
Input
2 0 3
Output
IMPOSSIBLE

Water First Test
Input
1 0 1
Output
POSSIBLE

Water First Validator Validator
Input
2 0 1
Output
POSSIBLE

Separation Test
Input
0 6 2
Output
POSSIBLE

Separation Validator Validator
Input
0 8 3
Output
POSSIBLE

Too Hot Test
Input
0 5 1
Output
IMPOSSIBLE

Too Hot Validator Validator
Input
0 6 1
Output
IMPOSSIBLE

Nobody Interested Test
Input
0 0 0
Output
IMPOSSIBLE

Nobody Interested Validator Validator
Input
0 0 0
Output
IMPOSSIBLE

Fireworks Test
Input
5 25 4
Output
POSSIBLE

Fireworks Validator Validator
Input
3 21 5
Output
POSSIBLE

Conspiracy Test
Input
20 20 22
Output
IMPOSSIBLE

Conspiracy Validator Validator
Input
10 10 12
Output
IMPOSSIBLE

The Biggest Parade in the World Test
Input
1000000000 1000000000 1000000000
Output
POSSIBLE

The Biggest Parade in the World Validator Validator
Input
999999999 999999999 999999999
Output
POSSIBLE

Explosion Test
Input
5 38 10
Output
IMPOSSIBLE

Explosion Validator Validator
Input
7 48 12
Output
IMPOSSIBLE

Lonely Mage Test
Input
0 0 1
Output
POSSIBLE

Lonely Mage Validator Validator
Input
0 1 0
Output
POSSIBLE

Scorched Earth Test
Input
100000000 1000000000 100000000
Output
IMPOSSIBLE

Scorched Earth Validator Validator
Input
199999999 1000000000 200000000
Output
IMPOSSIBLE

The Hottest Parade Test
Input
200000000 1000000000 200000000
Output
POSSIBLE

The Hottest Parade Validator Validator
Input
199999999 999999993 199999999
Output
POSSIBLE

Undividable Test
Input
1 1 3
Output
IMPOSSIBLE

Undividable Validator Validator
Input
3 2 5
Output
IMPOSSIBLE

Solution language

Solution

Stub generator input