Submission #495319

#TimeUsernameProblemLanguageResultExecution timeMemory
495319600MihneaMonochrome Points (JOI20_monochrome)C++17
25 / 100
2091 ms332 KiB
#include <iostream> #include <vector> #include <string> #include <functional> #include <cassert> using namespace std; typedef long long ll; const int N = 400000 + 7; int n; string s; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> s; vector<int> a, b; for (int i = 0; i < 2 * n; i++) { if (s[i] != s[0]) { a.push_back(i); } else { b.push_back(i); } } vector<ll> cnt(n); ll sol = 0; for (int shift = 0; shift < n; shift++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (min(a[i], b[(i + shift) % n]) < min(a[j], b[(j + shift) % n]) && min(a[j], b[(j + shift) % n]) < max(a[i], b[(i + shift) % n]) && max(a[i], b[(i + shift) % n]) < max(a[j], b[(j + shift) % n])) { cnt[shift]++; } } } } for (auto& x : cnt) { sol = max(sol, x); } cout << sol << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...