Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 506a6a8

Browse files
committed
➕ add sample file
1 parent 4434dd4 commit 506a6a8

File tree

2 files changed

+232
-1
lines changed

2 files changed

+232
-1
lines changed

Scripts/Web_Scrappers/CodeChef_Scraper/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
2+
The Fools Who Dream
3+
Problem Code: LALALANT
4+
5+
6+
7+
8+
My ant used to live in Paris. But now, he lives in La La Land, because of lower rents. There's only one disadvantage in living there: traveling in La La Land is a nightmare.
9+
La La Land is a rectangular grid with dimensions r×cr×cr\times c (rrr rows, ccc columns). Each cell can only have one of three colors: black, red, and white. And as you know, ants are colored either black or red. But because the mayor of La La Land is a bit crazy, he requires every walking ant in La La Land to follow these rules:
10+
11+
A walking ant must always be facing in one of the four cardinal directions: north, south, east and west.
12+
A walking ant that goes into a white cell must keep walking forward, not changing directions.
13+
A walking ant that goes into a non-white cell with the same color as itself must turn left 90 degrees exactly once, and then keep walking forward.
14+
A walking ant that goes into a non-white cell with a different color from itself must turn right 90 degrees exactly once, and then keep walking forward.
15+
A walking ant that goes off the grid is foolish. It is very hard to go back into La La Land without tons of paperwork, so we can assume that a walking ant that goes off the grid will stay outside the grid forever.
16+
17+
As you can see, once an ant begins walking, it doesn't really have any choice. The ant's path is fully determined by the grid.
18+
My ant is a black ant, and he wants to build a house in one of the cells in La La Land, and live there with his friend, which is a red ant. They also want to build their garage in one of the cells. The mayor has additional rules regarding houses and garages:
19+
20+
There must be exactly one house and one garage.
21+
The cells containing the house and the garage must be different.
22+
The cells containing the house and the garage must be white cells.
23+
The house must have exactly one door, and it must point in one of the four cardinal directions. Thus, any walking ant leaving the house will be facing in that direction.
24+
25+
Luckily, the garage can be entered from any direction, and the house and the garage cells don't have to be adjacent to each other.
26+
Furthermore, my ant and his friend behave in the following way:
27+
28+
If they reach the cell containing the house again, they just keep walking forward (since that cell is white). Note that this is not considered as "walking out of the house", so in particular, they will keep their current direction and not switch to the direction of the door.
29+
As soon as they reach the cell containing the garage, they immediately stop walking. (They will then ride their car. Yes, these ants are rich.)
30+
31+
My ant, which is a black ant, has a special subset BBB of the cells that he wants to visit every time he walks out from his house. His friend, which is a red ant, also has a special subset RRR of the cells that she wants to visit every time she walks out from her house. They may optionally visit other cells outside their special subset, but they must visit all cells in their special subset. Also, they must end their walk at the garage.
32+
You are friends with the mayor, and so you managed to talk him into changing the colors of the cells for you. The mayor has given you complete freedom to choose the color of every cell in the grid with only one restriction: since the mayor is a red ant, he doesn't like black, so he requires the final grid to have at most 111111 black cells.
33+
Help my ant and his friend achieve their dream, foolish as they may seem, by choosing the coloring of the grid (subject to the mayor's restriction), choosing the locations of the house and the garage, and choosing where the door of the house points to. Or, if it is impossible, say so as well.
34+
"A bit of madness is key
35+
to give us new colors to see.
36+
Who knows where it will lead us?
37+
And that's why they need us."
38+
Input
39+
The first line contains TTT, the number of test cases. The following lines describe the test cases.
40+
The first line of each test case contains four space-separated integers rrr, ccc, |B||B||B| and |R||R||R|, where |B||B||B| and |R||R||R| denote the sizes of BBB and RRR, respectively.
41+
Each of the next |B||B||B| lines contains two space-separated integers iii and jjj denoting that the cell at row iii and column jjj is in BBB.
42+
Each of the next |R||R||R| lines contains two space-separated integers iii and jjj denoting that the cell at row iii and column jjj is in RRR.
43+
Output
44+
For each test case, first output a single line containing either POSSIBLE (if it is possible) or FOOLISH (if it is impossible). In addition, if it is possible, you need to output at least one valid coloring. Output rrr more lines, each containing a string of length ccc whose letters are one of the following:
45+
46+
B denoting a black cell;
47+
R denoting a red cell;
48+
W denoting a white cell;
49+
G denoting a white cell containing the garage;
50+
^ denoting a white cell containing a house with door pointing north;
51+
v denoting a white cell containing a house with door pointing south;
52+
( denoting a white cell containing a house with door pointing west;
53+
) denoting a white cell containing a house with door pointing east.
54+
55+
We assume that north is up, south is down, west is left, and east is right. Note that:
56+
57+
There must be exactly one cell containing G.
58+
There must be exactly one cell containing one of the characters ^, v, ( or ).
59+
There must be at most 111111 cells containing B.
60+
61+
There may be multiple possible answers; any one will be accepted.
62+
Constraints
63+
64+
1≤T≤1051≤T≤1051 \leq T \leq 10^5
65+
1≤r,c≤1501≤r,c≤1501 \le r, c \le 150
66+
1≤i≤r1≤i≤r1 \le i \le r
67+
1≤j≤c1≤j≤c1 \le j \le c
68+
0≤|B|,|R|≤5000≤|B|,|R|≤5000 \le |B|, |R| \le 500
69+
The sum of the rcrcrc in a single file is ≤5⋅106≤5⋅106\le 5\cdot 10^6
70+
The sum of the |B||B||B| in a single file is ≤106≤106\le 10^6
71+
The sum of the |R||R||R| in a single file is ≤106≤106\le 10^6
72+
73+
Sample Input
74+
3
75+
6 11 5 3
76+
5 5
77+
5 8
78+
5 9
79+
6 8
80+
6 9
81+
1 5
82+
3 2
83+
4 9
84+
7 5 4 3
85+
6 1
86+
4 2
87+
5 2
88+
7 2
89+
3 5
90+
5 2
91+
7 2
92+
2 2 1 1
93+
1 2
94+
2 1
95+
96+
Sample Output
97+
POSSIBLE
98+
WWWBWWWBWWR
99+
WRWWWWWWWBW
100+
W)WRWWBWWWR
101+
WWWWBBRRWGR
102+
WWWBWWWWRRR
103+
WBWWRWRRRRR
104+
POSSIBLE
105+
RWWRW
106+
RWBRB
107+
WBBWB
108+
WWWBW
109+
BR^WB
110+
WWWWB
111+
BGBWW
112+
FOOLISH
113+
114+
Explanation
115+
Here's an illustration of the output for the first two test cases.
116+
117+
118+
The Fools Who Dream
119+
Problem Code: LALALANT
120+
121+
122+
123+
124+
My ant used to live in Paris. But now, he lives in La La Land, because of lower rents. There's only one disadvantage in living there: traveling in La La Land is a nightmare.
125+
La La Land is a rectangular grid with dimensions r×cr×cr\times c (rrr rows, ccc columns). Each cell can only have one of three colors: black, red, and white. And as you know, ants are colored either black or red. But because the mayor of La La Land is a bit crazy, he requires every walking ant in La La Land to follow these rules:
126+
127+
A walking ant must always be facing in one of the four cardinal directions: north, south, east and west.
128+
A walking ant that goes into a white cell must keep walking forward, not changing directions.
129+
A walking ant that goes into a non-white cell with the same color as itself must turn left 90 degrees exactly once, and then keep walking forward.
130+
A walking ant that goes into a non-white cell with a different color from itself must turn right 90 degrees exactly once, and then keep walking forward.
131+
A walking ant that goes off the grid is foolish. It is very hard to go back into La La Land without tons of paperwork, so we can assume that a walking ant that goes off the grid will stay outside the grid forever.
132+
133+
As you can see, once an ant begins walking, it doesn't really have any choice. The ant's path is fully determined by the grid.
134+
My ant is a black ant, and he wants to build a house in one of the cells in La La Land, and live there with his friend, which is a red ant. They also want to build their garage in one of the cells. The mayor has additional rules regarding houses and garages:
135+
136+
There must be exactly one house and one garage.
137+
The cells containing the house and the garage must be different.
138+
The cells containing the house and the garage must be white cells.
139+
The house must have exactly one door, and it must point in one of the four cardinal directions. Thus, any walking ant leaving the house will be facing in that direction.
140+
141+
Luckily, the garage can be entered from any direction, and the house and the garage cells don't have to be adjacent to each other.
142+
Furthermore, my ant and his friend behave in the following way:
143+
144+
If they reach the cell containing the house again, they just keep walking forward (since that cell is white). Note that this is not considered as "walking out of the house", so in particular, they will keep their current direction and not switch to the direction of the door.
145+
As soon as they reach the cell containing the garage, they immediately stop walking. (They will then ride their car. Yes, these ants are rich.)
146+
147+
My ant, which is a black ant, has a special subset BBB of the cells that he wants to visit every time he walks out from his house. His friend, which is a red ant, also has a special subset RRR of the cells that she wants to visit every time she walks out from her house. They may optionally visit other cells outside their special subset, but they must visit all cells in their special subset. Also, they must end their walk at the garage.
148+
You are friends with the mayor, and so you managed to talk him into changing the colors of the cells for you. The mayor has given you complete freedom to choose the color of every cell in the grid with only one restriction: since the mayor is a red ant, he doesn't like black, so he requires the final grid to have at most 111111 black cells.
149+
Help my ant and his friend achieve their dream, foolish as they may seem, by choosing the coloring of the grid (subject to the mayor's restriction), choosing the locations of the house and the garage, and choosing where the door of the house points to. Or, if it is impossible, say so as well.
150+
"A bit of madness is key
151+
to give us new colors to see.
152+
Who knows where it will lead us?
153+
And that's why they need us."
154+
Input
155+
The first line contains TTT, the number of test cases. The following lines describe the test cases.
156+
The first line of each test case contains four space-separated integers rrr, ccc, |B||B||B| and |R||R||R|, where |B||B||B| and |R||R||R| denote the sizes of BBB and RRR, respectively.
157+
Each of the next |B||B||B| lines contains two space-separated integers iii and jjj denoting that the cell at row iii and column jjj is in BBB.
158+
Each of the next |R||R||R| lines contains two space-separated integers iii and jjj denoting that the cell at row iii and column jjj is in RRR.
159+
Output
160+
For each test case, first output a single line containing either POSSIBLE (if it is possible) or FOOLISH (if it is impossible). In addition, if it is possible, you need to output at least one valid coloring. Output rrr more lines, each containing a string of length ccc whose letters are one of the following:
161+
162+
B denoting a black cell;
163+
R denoting a red cell;
164+
W denoting a white cell;
165+
G denoting a white cell containing the garage;
166+
^ denoting a white cell containing a house with door pointing north;
167+
v denoting a white cell containing a house with door pointing south;
168+
( denoting a white cell containing a house with door pointing west;
169+
) denoting a white cell containing a house with door pointing east.
170+
171+
We assume that north is up, south is down, west is left, and east is right. Note that:
172+
173+
There must be exactly one cell containing G.
174+
There must be exactly one cell containing one of the characters ^, v, ( or ).
175+
There must be at most 111111 cells containing B.
176+
177+
There may be multiple possible answers; any one will be accepted.
178+
Constraints
179+
180+
1≤T≤1051≤T≤1051 \leq T \leq 10^5
181+
1≤r,c≤1501≤r,c≤1501 \le r, c \le 150
182+
1≤i≤r1≤i≤r1 \le i \le r
183+
1≤j≤c1≤j≤c1 \le j \le c
184+
0≤|B|,|R|≤5000≤|B|,|R|≤5000 \le |B|, |R| \le 500
185+
The sum of the rcrcrc in a single file is ≤5⋅106≤5⋅106\le 5\cdot 10^6
186+
The sum of the |B||B||B| in a single file is ≤106≤106\le 10^6
187+
The sum of the |R||R||R| in a single file is ≤106≤106\le 10^6
188+
189+
Sample Input
190+
3
191+
6 11 5 3
192+
5 5
193+
5 8
194+
5 9
195+
6 8
196+
6 9
197+
1 5
198+
3 2
199+
4 9
200+
7 5 4 3
201+
6 1
202+
4 2
203+
5 2
204+
7 2
205+
3 5
206+
5 2
207+
7 2
208+
2 2 1 1
209+
1 2
210+
2 1
211+
212+
Sample Output
213+
POSSIBLE
214+
WWWBWWWBWWR
215+
WRWWWWWWWBW
216+
W)WRWWBWWWR
217+
WWWWBBRRWGR
218+
WWWBWWWWRRR
219+
WBWWRWRRRRR
220+
POSSIBLE
221+
RWWRW
222+
RWBRB
223+
WBBWB
224+
WWWBW
225+
BR^WB
226+
WWWWB
227+
BGBWW
228+
FOOLISH
229+
230+
Explanation
231+
Here's an illustration of the output for the first two test cases.
232+

0 commit comments

Comments
 (0)