Submission #296139

#TimeUsernameProblemLanguageResultExecution timeMemory
296139PyqeMonochrome Points (JOI20_monochrome)C++14
100 / 100
45 ms2880 KiB
#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)

monochrome.cpp: In function 'int main()':
monochrome.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%lld",&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...