Sajam
의견: 0
5 \(s / 64\) \(MB / 90\) points
In the spirit of advent Milo organized his own Christmas fair. It will be the best one in Europe! The
evening ends and the moment has come to turn off the lights. Some were so insolent that they didn’t
even deign to turn off lights on their stands! Since the electricity is more and more expensive, Milo
wants all the lights to be turned off quickly. For this he will use the l egendary- e lectric- e lectronic- t ablet
( LEET ), but he also needs your help.
Milo's Christmas fair consists of stalls that are arranged in \(N\) rows of which every consists of \(N\)
stands. On his LEET Milo has 2 buttons:
●
By pressing the first button, Milo imagines one row, \(x\) .
LEET then lights every stand of the \(x\) ^{th} row that had been turned off, but also turns off every
stand of the \(x\) {th}{ } row that had been turned on.
●
By pressing the second button, Milo imagines one column, \(x\) .
LEET then lights every stand of the \(x\) ^{th} column that had been turned off, but also turns off
every stand of the \(x\) {th}{ }column that had been turned on.
By pressing his own belly button (the “third button”), Milo will decide to walk to a particular stand and
physically turn it on (or turn it off). The problem is that he has injured his leg so in order not to get a
pulmonary embolism, the doctor has prescribed that the “third button” should be pressed at most \(K\)
times ( \(K \le N\) ). Fortunately, the first and second button he can press as much as he wants.
Is it possible that Milo will shut down all the stands with arbitrary sequence of actions?
In the test samples worth at least 15 points it will hold \(K\) = 0.
In the additional test samples worth at least 15 points N will be less or equal to 100.
In the additional test samples worth at least 30 points \(K\) will strictly be less than 1⁄2 N.
5 \(s / 64\) \(MB / 90\) points
In the first line of input there are two integer numbers \(N\) and \(K\) from the task description
(1 ≤ \(N\) ≤ 1 000, 0 ≤ \(K\) ≤ \(N\) ).
In the next \(N\) lines there are \(N\) characters 'x' or 'o', the initial state of the stands of the Christmas fair.
The symbol 'x' represents a stand that is turned off and 'o' a stand that is turned on.
Print the answer to the question from the task: “DA” (Croatian for yes) if possible or “NE” (Croatian for
no) if it is not (without the quotation marks).
2 0
ox
ox
3 1
ooo
xoo
oox
4 2
oxxo
xxox
oxoo
oxxooutput
output
DA
NE
DAExplanation of the third test sample:
One possible sequence of button pressures is given after which all the stands are turned off:
●
Second button (imagine column 1).
●
Third button (turn on field (2, 2)).
●
First button (imagine row 2).
●
Second button (imagine column 4).
●
Third button (turn off field (3, 3)).
평가 및 의견
Sajam
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Sajam