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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:17:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<s.size();j++)
                     ~^~~~~~~~~

Code

#include <bits/stdc++.h>

using namespace std;

int t;

int main()
{
    cin>>t;
    string s;
    for(int i=0;i<t;i++)
    {
        cin>>s;
        string so = s;
        sort(s.begin(), s.end());
        int r = 0;
        for(int j=0;j<s.size();j++)
        {
            if(s[j] != so[j]) r++;
        }
        cout<<r/2<<'\n';
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
BBAABBBBAAABABBBAABBAABAAAABBB...

correct output
10
10
20
3
20
...

user output
10
10
20
3
20
...