#P9868. [NOIP2023] 词典
[NOIP2023] 词典
Problem Description
Xiao S has pairwise distinct words in the dictionary, each with length . Each word is a string consisting of lowercase letters.
Xiao S may perform the following operation any number of times (possibly zero times): choose any word in the dictionary and swap any two characters in it.
For each , Xiao S wants to know whether it is possible, through the operations above, to obtain new words such that for every , is lexicographically smaller than . For the case , we agree that the property above naturally holds.
For two strings of the same length and , we say that is lexicographically smaller than if and only if the following holds: there exists a position such that and are identical before the -th character, and , i.e., the lowercase letter comes before in alphabetical order.
Input Format
The first line contains two positive integers and , representing the number of words and the length of each word.
The next lines each contain a lowercase string of length , representing a word.
Output Format
Output one line containing a 01 string of length . For , if the property described in the statement holds, then 1; otherwise, 0.
4 7
abandon
bananaa
baannaa
notnotn
1110
Hint
[Sample Explanation #1]
- Without any operation, the first word is lexicographically smallest, so the first character of the output is
1. - Swap the first two characters of
bananaa, and swap the third and sixth characters ofabandon, obtainingabondan,abnanaa,baannaa,notnotn. Now the second word is lexicographically smallest, so the second character of the output is1. - Swap the first and last characters of
baannaato getaaannab, leaving the other strings unchanged. Now the third word is lexicographically smallest, so the third character of the output is1. - No matter how you operate, the fourth word will not be smaller than the second word, so the fourth character of the output is
0.
[Sample Explanation #2]
This sample satisfies the limits of test point .
[Sample Explanation #3]
This sample satisfies the limits of test point .
[Sample Explanation #4]
This sample satisfies the limits of test point .
[Constraints]
For all testdata, it is guaranteed that: , , each is a lowercase string of length , and all words are pairwise distinct.
| Test Point ID | ||
|---|---|---|
Translated by ChatGPT 5