| Task: | Järjestys |
| Sender: | Mahtimursu |
| Submission time: | 2022-01-22 13:01:32 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 100 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | details |
Code
#include <bits/stdc++.h>
typedef long long ll;
#define M 1000000007
#define N (1 << 18)
using namespace std;
void test_case() {
string s;
cin >> s;
int n = s.size();
string cp = s;
sort(cp.begin(), cp.end());
int cnt = 0;
for (int i = 0; i < n; ++i) {
if (cp[i] != s[i]) cnt++;
}
cout << cnt / 2;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
for (int i = 0; i < t; ++i) {
test_case();
cout << "\n";
}
return 0;
}