CSES - Datatähti 2022 loppu - Results
Submission details
Task:Järjestys
Sender:Mahtimursu
Submission time:2022-01-22 13:01:32 +0200
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails

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;
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
BBAABBBBAAABABBBAABBAABAAAABBB...

correct output
10
10
20
3
20
...

user output
10
10
20
3
20
...
Truncated