CF 797, got stuck on E and had to leave, went pretty well
This commit is contained in:
68
codeforces/rounds/797/d.cpp
Normal file
68
codeforces/rounds/797/d.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void test_case(int tc){
|
||||
int n, k;
|
||||
cin >> n >> k;
|
||||
|
||||
vector<bool> strip;
|
||||
|
||||
int blacks = 0;
|
||||
int whites = 0;
|
||||
for(int i = 0; i < k; ++i){
|
||||
char c;
|
||||
cin >> c;
|
||||
|
||||
if(c == 'B'){
|
||||
blacks++;
|
||||
strip.push_back(true);
|
||||
} else{
|
||||
whites++;
|
||||
strip.push_back(false);
|
||||
}
|
||||
}
|
||||
|
||||
int min_whites = whites;
|
||||
|
||||
for(int i = 0; i < n - k; ++i){
|
||||
char c;
|
||||
cin >> c;
|
||||
|
||||
if(strip[i]){
|
||||
blacks--;
|
||||
} else {
|
||||
whites--;
|
||||
}
|
||||
|
||||
if(c == 'B'){
|
||||
blacks++;
|
||||
strip.push_back(true);
|
||||
} else {
|
||||
whites++;
|
||||
strip.push_back(false);
|
||||
}
|
||||
|
||||
min_whites = min(min_whites, whites);
|
||||
}
|
||||
|
||||
cout << min_whites << '\n';
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
for(int tc = 1; tc <= t; ++tc){
|
||||
test_case(tc);
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user