diff --git a/Luogu/P1360/P1360.cpp b/Luogu/P1360/P1360.cpp new file mode 100644 index 00000000..8760bf12 --- /dev/null +++ b/Luogu/P1360/P1360.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +int n, m, ans; +std::map, int> map; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m; + + std::vector 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; +}