Z
Z
ZiGR2013-03-10 23:45:42
Algorithms
ZiGR, 2013-03-10 23:45:42

Solving the problem "Garlands", DonNU?

At the moment, the VI Regional Olympiad of DonNU has ended. As promised, I'm reposting this question.
Among the tasks there is a very interesting task, which is called "Garlands", connected with physics.
As far as I know, no one solved this problem even at the Kharkiv Open Programming Championship. I would like to hear Habr's ideas.
Limitations
Memory limit: 64 MB
Time limit: 2 s.
Allowed use: Pascal (FreePascal 2.4.2/Delphi Compiler 15.0), C/C++ (MinGW 3.4.2, Microsoft Visual C++ 2008/2010/2012)
Task Text
For the New Year, robots dressed up the computer with a luminous garland of light bulbs mounted on a square grid of a breadboard. Voltage is connected to the top left and bottom right corners of the breadboard. All bulbs are the same and glow even at very low currents. In the midst of preparations, one of the bulbs burned out. The robots are very busy preparing, so they entrusted you with a responsible task - to determine which bulbs in the garland will remain constantly lit, albeit weakly. The voltage is assumed to be constant (the garland was powered from the computer power supply), so the effects of capacitance and inductance do not need to be taken into account.
Input data format
The first line contains two integers: N — the number of grid cells vertically and M — horizontally. Followed by (2N+1) string. Each odd line contains M numbers — the values ​​of the horizontal conductors. Each even line contains (M+1) number — the values ​​of the vertical conductors. The number 0 in the line means that the conductor is missing (in the figure it is represented by a dotted line), the number 1 - there is a conductor with a light bulb, the number 2 indicates a burnt out light bulb (in the figure - a dotted light bulb). It is guaranteed that there is exactly one 2 among the input data.
0 ≤ N ≤ 10, 0 ≤ M ≤ 10.
Output format
The output should contain a matrix (similar to the input matrix), in which the number 0 means no conductor with a light bulb, 1 - there is a conductor and the light is on, 2 - there is a conductor with a light bulb, but the lamp is not on.
task11.png
Examples of input and output data:
70c39cbd8edac68898ba4c77f3318440.png

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Arktos, 2013-03-11
@Arktos

It is not correct to discuss the problem before the end of the Olympiad

B
Brand, 2013-03-11
@Brand

*removed

F
FilimoniC, 2013-03-11
@FilimoniC

The picture doesn't match the data

F
FilimoniC, 2013-03-11
@FilimoniC

By the way, a very strange limitation of 64 megabytes. Too much. for the indicated 2s, not every hard disk will have time to read this program, let alone execute

N
Nurzhan Bakibaev, 2013-03-11
@Hypuk

Is this problem on some online judge to check the solution?

I
ivnik, 2013-03-11
@ivnik

Floyd-Warshall algorithm?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question