#P7376. [COCI 2018/2019 #5] Ispit
[COCI 2018/2019 #5] Ispit
Description
You are given an by matrix consisting of lowercase letters and an integer . Is there a set of consecutive columns such that, within these columns, for every row you may rearrange the letters inside that row (that is, you can only swap letters within the same row), and after doing so, the original matrix can have two rows that are exactly identical?
Input Format
The first line contains integers .
The next lines each contain characters, representing the original letter matrix.
Output Format
If there is a solution that satisfies the requirement, output DA; otherwise output NE.
4 2
abcd
acbd
enaa
moze
DA
2 2
aa
aa
DA
3 2
nec
uuc
iti
NE
Hint
Sample 1 Explanation
Choose columns , and swap the letters in these two columns within rows , obtaining the new matrix:
abcd
abcd
eana
mzoe
Now rows and are exactly the same, so the requirement is satisfied.
Constraints
For all testdata, the input matrix is guaranteed to consist of lowercase letters.
For of the testdata, .
For another of the testdata, .
For of the testdata, .
Notes
The score for this problem follows the original COCI setting, with a full score of .
This problem is translated from COCI2018-2019 CONTEST #5 T3 Ispit.
Translated by ChatGPT 5
京公网安备 11011102002149号