Submission #1263606

#TimeUsernameProblemLanguageResultExecution timeMemory
1263606ivopavMonochrome Points (JOI20_monochrome)C++20
25 / 100
2093 ms440 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
    srand(0);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    vector<int> cor(n,0);
    vector<int> pov(n,0);
    int isp=0;
    for (int k=0;k<n*2;k++){
        int ind1=0;
        int ind2=k;
        for (int i=0;i<n;i++){
            while (s[ind1]=='B'){
                ind1++;
            }
            cor[i]=ind1;
            while (s[ind2]=='W'){
                ind2++;
                ind2%=n*2;
            }
            pov[i]=ind2;
            ind1++;
            ind1%=n*2;
            ind2++;
            ind2%=n*2;
    
        }
        int rje=0;
        for (int i=0;i<n;i++){
            for (int j=i+1;j<n;j++){
                int ind1w=cor[i];
                int ind2w=cor[j];
                int ind1b=pov[i];
                int ind2b=pov[j];
                ind2w-=ind1w;
                ind2w+=n*2;
                ind2w%=n*2;
                ind1b-=ind1w;
                ind1b+=n*2;
                ind1b%=n*2;
                ind2b-=ind1w;
                ind2b+=n*2;
                ind2b%=n*2;
                ind1w=0;
           //     cout << ind1w+1 << " " << ind2w+1 << " " << ind1b+1 << " " << ind2b+1 << "\n";
             //   cout << cor[i]+1 << " " << cor[j]+1 << " " << pov[i]+1 << " " << pov[j]+1 << "\n"; 
                if (min(ind2w,ind2b)<ind1b && max(ind2w,ind2b)>ind1b){
                    rje++;
               //     cout << "+\n";
                }
                
                
            }
        }
        isp=max(isp,rje);
    }
    
    cout << isp << "\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...