Submission #502576

#TimeUsernameProblemLanguageResultExecution timeMemory
502576amunduzbaevMonochrome Points (JOI20_monochrome)C++14
25 / 100
2015 ms352 KiB
#include "bits/stdc++.h" using namespace std; #define ar array signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; string s; cin>>s; ar<vector<int>, 2> p; for(int i=0;i<2*n;i++){ p[s[i] == 'B'].push_back(i); } int rr = 0; for(int k=0;k<n;k++){ vector<ar<int, 2>> a(n); int res = 0; for(int i=0;i<n;i++){ int j = (i + k) % n; a[i] = {p[0][i], p[1][j]}; if(a[i][0] > a[i][1]) swap(a[i][0], a[i][1]); } auto check = [&](ar<int, 2> a, ar<int, 2> b){ if(a[0] < b[0] && b[1] < a[1]) return; if(b[0] < a[0] && a[1] < b[1]) return; res += (max(a[0], b[0]) < min(a[1], b[1])); }; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ check(a[i], a[j]); } } rr = max(rr, res); } cout<<rr<<"\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...