This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
int n;
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int> a,b;
cin>>n;
for (int i=0;i<2*n;i++){
char c;cin>>c;
if (c=='W') a.pb(i);
else b.pb(i);
}int ans=0;
do{
int x=0;
for (int i=0;i<n;i++){
for (int j=i+1;j<n;j++){
int x1=b[i],y1=a[i],x2=b[j],y2=a[j];
if (x1>y1) swap(x1,y1);
if (x2>y2) swap(x2,y2);
x+=(bool(x2<y1 && x2>x1)+bool(y2<y1 && y2>x1))%2;
}
}ans=max(ans,x);
}while (next_permutation(a.begin(),a.end()));
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |