0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 18:48:48 +00:00

P1360 [USACO07MAR]Gold Balanced Lineup G

https://www.luogu.com.cn/record/87243916
This commit is contained in:
Baoshuo Ren 2022-09-23 07:48:11 +08:00
parent cc65e1dbae
commit 3c491fbe2c
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

43
Luogu/P1360/P1360.cpp Normal file
View 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;
}