#P7315. [COCI 2018/2019 #3] Sajam
[COCI 2018/2019 #3] Sajam
Description
Each area consists of rows, and each row has stalls. There are types of operations to change the lighting state (changing a lit lamp to unlit, and vice versa):
- LEET selects an entire row and automatically toggles the lighting state of all lamps in that row.
- LEET selects an entire column and automatically toggles the lighting state of all lamps in that column.
- Milo selects one stall and manually toggles the lighting state of the lamp at that stall.
Is there a way for Milo to turn off all lamps, using operation 3 at most times?
Input Format
The first line contains integers .
The next lines each contain characters x or o, representing the lighting state of the lamps at the corresponding stalls in the Christmas fair. Here, x means unlit, and o means lit.
Output Format
If there is a plan that satisfies the requirement, output DA; otherwise output NE.
2 0
ox
ox
DA
3 1
ooo
xoo
oox
NE
4 2
oxxo
xxox
oxoo
oxxo
DA
Hint
Explanation for Sample 3
One feasible plan is:
- Perform operation , selecting column .
- Perform operation , selecting .
- Perform operation , selecting row .
- Perform operation , selecting column .
- Perform operation , selecting .
Constraints
For points, .
For another points, .
For another points, .
For of the testdata, , .
Notes
The scoring of this problem follows the original COCI settings, with a full score of . Only test points with different difficulties are selected for evaluation here.
Translated from COCI2018-2019 CONTEST #3 T3 Sajam.
Translated by ChatGPT 5
京公网安备 11011102002149号