Submission #306825

#TimeUsernameProblemLanguageResultExecution timeMemory
306825MrDominoMonochrome Points (JOI20_monochrome)C++14
25 / 100
2076 ms504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int N = (int) 2e5 + 7; int n; string s; vector<int> a; vector<int> b; int f(int l, int r, int x) { return (l <= x && x <= r); } ll get(int k) { vector<pair<int, int>> p; for (int i = 0; i < n; i++) { p.push_back({a[i], b[(i + k) % n]}); } for (auto &it : p) { if (it.second < it.first) { swap(it.first, it.second); } } ll sol = 0; for (int i = 0; i < (int) p.size(); i++) { for (int j = 0; j < i; j++) { sol += f(p[i].first, p[i].second, p[j].first) != f(p[i].first, p[i].second, p[j].second); } } return sol; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> s; for (int i = 0; i < 2 * n; i++) { if (s[i] == 'W') { a.push_back(i); } else { b.push_back(i); } } ll sol = 0; for (int k = 0; k < n; k++) { sol = max(sol, get(k)); } 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...