mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P1360 [USACO07MAR]Gold Balanced Lineup G
https://www.luogu.com.cn/record/87243916
This commit is contained in:
parent
cc65e1dbae
commit
3c491fbe2c
43
Luogu/P1360/P1360.cpp
Normal file
43
Luogu/P1360/P1360.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
int n, m, ans;
|
||||
std::map<std::vector<int>, int> map;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m;
|
||||
|
||||
std::vector<int> s(m);
|
||||
|
||||
map[s] = 0;
|
||||
for (int i = 1, x; i <= n; i++) {
|
||||
cin >> x;
|
||||
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (x >> j & 1) s[j]++;
|
||||
}
|
||||
|
||||
if (!std::count(s.begin(), s.end(), 0)) {
|
||||
for (int& x : s) x--;
|
||||
}
|
||||
|
||||
if (map.count(s)) {
|
||||
ans = std::max(ans, i - map[s]);
|
||||
} else {
|
||||
map[s] = i;
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user