Submission #1263600

#TimeUsernameProblemLanguageResultExecution timeMemory
1263600ivopavMonochrome Points (JOI20_monochrome)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
    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 ind1=0;
    int ind2=0;
    for (int i=0;i<n;i++){
        while (s[ind1]=='B'){
            ind1++;
        }
        cor[i]=ind1;
        while (s[ind2]=='W'){
            ind2++;
        }
        pov[i]=ind2;
        ind1++;
        ind1%=n*2;
        ind2++;
        ind2%=n*2;

    }
    int isp=0;
    for (int i=0;i<20;i++){
        random_shuffle(pov.begin(),pov.end());
        bool nas=1;
        while (nas){
            nas=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;
                    if (ind1b<ind2w || ind2b<ind2w){
                        continue;
                    }
                    if (ind1b>ind2b){
                        swap(pov[i],pov[j]);
                        nas=1;
                    }
                }
            }
        }
        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(rje,isp);
    }
    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...