Codeforces Round 905 (Div. 3)
A. Morning
模拟光标移动即可
void solve(){
string ss;
cin >> ss;
char ch = '1';
int ans = 0;
for(auto c : ss){
if(c != ch){
int x = c, y = ch;
if(c == '0') x = '9' + 1;
if(ch == '0') y = '9' + 1;
ans += abs(x - y);
ch = c;
}
++ ans;
}
cout << ans << '\n';
return ;
}
B. Chemistry
先统计
void solve(){
int n, k;
string ss;
cin >> n >> k >> ss;
vector<int> cnt(26, 0);
for(auto c : ss){
++ cnt[c - 'a'];
}
int shu[2] = {0, 0};
for(int i = 0; i < 26; ++ i)
if(cnt[i]) ++ shu[cnt[i] % 2];
if(k >= shu[1] - 1) cout << "YES\n";
else cout << "NO\n";
return ;
}