# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
296139 | Pyqe | Monochrome Points (JOI20_monochrome) | C++14 | 45 ms | 2880 KiB |
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>
using namespace std;
long long n,ps[200069];
bitset<400069> a;
int main()
{
long long i,z;
string s;
scanf("%lld",&n);
z=n*(n-1)/2;
cin>>s;
for(i=1;i<=n*2;i++)
{
a[i]=s[i-1]=='W';
}
for(i=1;i<=n;i++)
{
ps[i]=ps[i-1]+((!a[i]*2-1)*(a[i]==a[n+i]));
}
sort(ps+1,ps+n+1);
for(i=1;i<=n;i++)
{
z-=abs(ps[i]-ps[(n+1)/2]);
}
printf("%lld\n",z);
}
Compilation message (stderr)
# | 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... |