Submission #709690

#TimeUsernameProblemLanguageResultExecution timeMemory
709690AntekbMonochrome Points (JOI20_monochrome)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> #define st first #define nd second #define eb emplace_back #define pb push_back #define pp pop_back #define all(x) x.begin(), x.end() using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; void debug(){cerr<<"\n";} template<typename H, typename... T> void debug(H h, T... t){cerr<<h;if(sizeof...(t))cerr<<", ";debug(t...);}; #define deb(x...) cerr<<#x<<" = ";debug(x); mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const int N=1e5+5, INF=1e9+5; int main(){ //ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; string s; cin>>s; int wsk=n, wsk2=n; vi V(n); for(int i=0; i<n; i++){ //deb(wsk, wsk2); if(s[i]=='B'){ while(s[wsk]=='B')wsk++; V[wsk-n]=i; wsk++; } else{ while(s[wsk2]=='W')wsk2++; V[wsk2-n]=i; wsk2++; } } int ans=0; for(int i=0; i<n; i++){ //deb(V[i]); for(int j=i+1; j<n; j++){ if(V[i]<V[j])ans++; } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...