bzoj#P1702. [Usaco2007 Mar]Gold Balanced Lineup 平衡的队列
[Usaco2007 Mar]Gold Balanced Lineup 平衡的队列
题目描述
Farmer John's cows share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only different features . For example, cows exhibiting feature #1 might have spots, cows exhibiting feature #2 might prefer C to Pascal, and so on. FJ has even devised a concise way to describe each cow in terms of its "feature ID", a single k-bit integer whose binary representation tells us the set of features exhibited by the cow. As an example, suppose a cow has feature ID = . Since written in binary is , this means our cow exhibits features , , and (reading right to left), but not feature . More generally, we find a in the place if a cow exhibits feature . Always the sensitive fellow, FJ lined up cows in a long row and noticed that certain ranges of cows are somewhat "balanced" in terms of the features the exhibit. A contiguous range of cows is balanced if each of the possible features is exhibited by the same number of cows in the range. FJ is curious as to the size of the largest balanced range of cows. See if you can determine it.
头牛,一共 种特色,每头牛有多种特色,用二进制 表示它的特色 ID。比如特色 ID 为 ,则它有第 、、 种特色。 段被称为 balanced 当且仅当 种特色在 内拥有次数相同。求最大的 段长度。
输入格式
- Line : Two space-separated integers, and .
- Lines : Line contains a single -bit integer specifying the features present in cow . The least-significant bit of this integer is if the cow exhibits feature #1, and the most-significant bit is if the cow exhibits feature #k.
输出格式
- Line : A single integer giving the size of the largest contiguous balanced group of cows.
7 3
7
6
7
2
1
4
2
4
样例说明
INPUT DETAILS:
The line has cows with features; the table below summarizes the correspondence:
Feature : | |||||||
---|---|---|---|---|---|---|---|
Feature : | |||||||
Feature : | |||||||
key: | |||||||
Cow #: |
OUTPUT DETAILS:
In the range from cow #3 to cow #6 (of size ), each feature appears in exactly cows in this range:
Feature : | -> two total | ||||
---|---|---|---|---|---|
Feature : | -> two total | ||||
Feature : | |||||
key: | |||||
Cow #: |
数据规模与约定
对于 的数据,,。
题目来源
鸣谢fjxmyzwd
Gold